public function activate($activate_token) //@todo: rename to 'activateUserAccount'
    {
        $return['error'] = true;
        $block_status = $this->isBlocked();

        if ($block_status == "block") {
            $return['message'] = $this->__lang("user_blocked");

            return $return;
        }

        if (strlen($activate_token) !== self::TOKEN_LENGTH) {
            $this->addAttempt();
            $return['message'] = $this->__lang("activationkey_invalid");

            return $return;
        }

        // 'user is already activated' will never triggered, because after successful activation token removed from DB
        // NOW is no any way to determine, is this token used for activation or not?

        $request_result = $this->getRequest($activate_token, "activation");

        if ($request_result['error']) {
            $return['message'] = $request_result['message'];

            return $return;
        }

        if ($this->getBaseUser($request_result['uid'])['isactive'] == 1) {
            $this->addAttempt();
            $this->deleteRequest($request_result['id']);
            $return['message'] = $this->__lang("system_error") . " #02"; // user activated, but activate token not expired

            return $return;
        }

        $query = "UPDATE {$this->config->table_users} SET isactive = :isactive WHERE id = :id";
        $query_prepared = $this->dbh->prepare($query);
        $query_params = [
            'isactive' => 1,
            'id' => $request_result['uid']
        ];
        $query_prepared->execute($query_params);

        $this->deleteRequest($request_result['id']);

        $return['error'] = false;
        $return['message'] = $this->__lang("account_activated");

        return $return;
    }
public function activate($activate_token) //@todo: rename to 'activateUserAccount'
    {
        $return['error'] = true;
        $block_status = $this->isBlocked();

        if ($block_status == "block") {
            $return['message'] = $this->__lang("user_blocked");

            return $return;
        }

        if (strlen($activate_token) !== self::TOKEN_LENGTH) {
            $this->addAttempt();
            $return['message'] = $this->__lang("activationkey_invalid");

            return $return;
        }

        // 'user is already activated' will never triggered, because after successful activation token removed from DB
        // NOW is no any way to determine, is this token used for activation or not?

        $request_result = $this->getRequest($activate_token, "activation");

        if ($request_result['error']) {
            $return['message'] = $request_result['message'];

            return $return;
        }

        if ($this->getBaseUser($request_result['uid'])['isactive'] == 1) {
            $this->addAttempt();
            $this->deleteRequest($request_result['id']);
            $return['message'] = $this->__lang("system_error") . " #02"; // user activated, but activate token not expired

            return $return;
        }

        $query = "UPDATE {$this->config->table_users} SET isactive = :isactive WHERE id = :id";
        $query_prepared = $this->dbh->prepare($query);
        $query_params = [
            'isactive' => 1,
            'id' => $request_result['uid']
        ];
        $query_prepared->execute($query_params);

        $this->deleteRequest($request_result['id']);

        $return['error'] = false;
        $return['message'] = $this->__lang("account_activated");

        return $return;
    }
public function activate ( $ activate_token ) //@todo: rename to 'activateUserAccount' { $ return [ 'error' ] = true ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "block" ) { $ return [ 'message' ] = $ this -> __lang ( "user_blocked" ) ; return $ return ; } if ( strlen ( $ activate_token ) !== self :: TOKEN_LENGTH ) { $ this -> addAttempt ( ) ; $ return [ 'message' ] = $ this -> __lang ( "activationkey_invalid" ) ; return $ return ; } // 'user is already activated' will never triggered, because after successful activation token removed from DB // NOW is no any way to determine, is this token used for activation or not? $ request_result = $ this -> getRequest ( $ activate_token , "activation" ) ; if ( $ request_result [ 'error' ] ) { $ return [ 'message' ] = $ request_result [ 'message' ] ; return $ return ; } if ( $ this -> getBaseUser ( $ request_result [ 'uid' ] ) [ 'isactive' ] == 1 ) { $ this -> addAttempt ( ) ; $ this -> deleteRequest ( $ request_result [ 'id' ] ) ; $ return [ 'message' ] = $ this -> __lang ( "system_error" ) . " #02" ; // user activated, but activate token not expired return $ return ; } $ query = "UPDATE {$this->config->table_users} SET isactive = :isactive WHERE id = :id" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; $ query_params = [ 'isactive' => 1 , 'id' => $ request_result [ 'uid' ] ] ; $ query_prepared -> execute ( $ query_params ) ; $ this -> deleteRequest ( $ request_result [ 'id' ] ) ; $ return [ 'error' ] = false ; $ return [ 'message' ] = $ this -> __lang ( "account_activated" ) ; return $ return ; }
Activates a user's account
@param string $activate_token
@return array $return
Activates a user s account