REST API Locked Account Enhancement

Discussion in 'Integration' started by bfritton, Jan 18, 2013.

  1. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    For those of you using the REST API free plugin, the check-access method will not return an error if the account is locked manually by an admin or by account sharing prevention methods by default.

    If you'd like to add this, open the CheckAccessController.php file in application/api/controllers/

    and add THIS chunk of code:

    PHP:
                /** CUSTOM: Fail user check if aMember account is locked */
                
    if($user->isLocked()) {
                    
    $ret['ok'] = false;
                    
    $ret['msg'] = 'Billing account is locked/suspended';
                    
    $ret['code'] = 'locked';
                }
                
    /** END CUSTOM */
    AFTER this chunk of code in the checkUser() function (the first function)

    PHP:
    if ($user)
            {
                
    $accessRecords $user->getActiveProductsExpiration();
                
    $ret = array(
                    
    'ok' => true,
                    
    'name' => $user->getName(),
                );
    You can change the error code and message to whatever you like.[/PHP]
  2. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    I should probably clarify that this is only for the check-by-email method, you would have to add that to the other methods if you're using the check-by-username or check-by-login methods.
  3. bfritton

    bfritton Certified aMember Developer

    Joined:
    Oct 26, 2009
    Messages:
    54
    Sorry, cancel that. the checkUser() method which I advised putting this code in at first is called by all those action methods.

Share This Page