public function authenticate($params, $method, $headers)
    {
        $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']);
        $password = $params['password'];

        $user = call_user_func(Manager::getUserGetByEmailMethod(), $email);

        if (!$user) {
            return false;
        }

        if (!password_verify($password, $user['password'])) {
            return false;
        }

        /*
         * Create the token as an array
        */
        $data = [
            'id' => $user['id']
        ];

        //copy user attributes to jwt's data
        foreach (Manager::getAttributes() as $attribute) {
            if (!isset($user[$attribute])) {
                throw new \Phramework\Exceptions\ServerException(sprintf(
                    'Attribute "%s" is not set in user object',
                    $attribute
                ));
            }
            $data[$attribute] = $user[$attribute];
        }

        //Convert to object
        $data = (object)$data;

        //Call onAuthenticate callback if set
        if (($callback = Manager::getOnAuthenticateCallback()) !== null) {
            call_user_func(
                $callback,
                $data
            );
        }

        return [$data];
    }
public function authenticate($params, $method, $headers)
    {
        $email = \Phramework\Validate\EmailValidator::parseStatic($params['email']);
        $password = $params['password'];

        $user = call_user_func(Manager::getUserGetByEmailMethod(), $email);

        if (!$user) {
            return false;
        }

        if (!password_verify($password, $user['password'])) {
            return false;
        }

        /*
         * Create the token as an array
        */
        $data = [
            'id' => $user['id']
        ];

        //copy user attributes to jwt's data
        foreach (Manager::getAttributes() as $attribute) {
            if (!isset($user[$attribute])) {
                throw new \Phramework\Exceptions\ServerException(sprintf(
                    'Attribute "%s" is not set in user object',
                    $attribute
                ));
            }
            $data[$attribute] = $user[$attribute];
        }

        //Convert to object
        $data = (object)$data;

        //Call onAuthenticate callback if set
        if (($callback = Manager::getOnAuthenticateCallback()) !== null) {
            call_user_func(
                $callback,
                $data
            );
        }

        return [$data];
    }
public function authenticate ( $ params , $ method , $ headers ) { $ email = \ Phramework \ Validate \ EmailValidator :: parseStatic ( $ params [ 'email' ] ) ; $ password = $ params [ 'password' ] ; $ user = call_user_func ( Manager :: getUserGetByEmailMethod ( ) , $ email ) ; if ( ! $ user ) { return false ; } if ( ! password_verify ( $ password , $ user [ 'password' ] ) ) { return false ; } /*
         * Create the token as an array
        */ $ data = [ 'id' => $ user [ 'id' ] ] ; //copy user attributes to jwt's data foreach ( Manager :: getAttributes ( ) as $ attribute ) { if ( ! isset ( $ user [ $ attribute ] ) ) { throw new \ Phramework \ Exceptions \ ServerException ( sprintf ( 'Attribute "%s" is not set in user object' , $ attribute ) ) ; } $ data [ $ attribute ] = $ user [ $ attribute ] ; } //Convert to object $ data = ( object ) $ data ; //Call onAuthenticate callback if set if ( ( $ callback = Manager :: getOnAuthenticateCallback ( ) ) !== null ) { call_user_func ( $ callback , $ data ) ; } return [ $ data ] ; }
Authenticate a user using JWT authentication method
@param  array  $params  Request parameters
@param  string $method  Request method
@param  array  $headers  Request headers
@return false|array  Returns false on failure
Authenticate a user using JWT authentication method