public function createAuthToken(
        $login,
        $password,
        $jwtWrapper,
        $expires = 1200,
        $updateUserInfo = [],
        $updateTokenInfo = []
    ) {
        if (!isset($login) || !isset($password)) {
            throw new InvalidArgumentException('Neither username or password can be empty!');
        }

        $user = $this->isValidUser($login, $password);
        if (is_null($user)) {
            throw new UserNotFoundException('User not found');
        }

        foreach ($updateUserInfo as $key => $value) {
            $user->set($key, $value);
        }

        $updateTokenInfo['login'] = $login;
        $updateTokenInfo['userid'] = $user->getUserid();
        $jwtData = $jwtWrapper->createJwtData(
            $updateTokenInfo,
            $expires
        );

        $token = $jwtWrapper->generateToken($jwtData);

        $user->set('TOKEN_HASH', sha1($token));
        $this->save($user);

        return $token;
    }
public function createAuthToken(
        $login,
        $password,
        $jwtWrapper,
        $expires = 1200,
        $updateUserInfo = [],
        $updateTokenInfo = []
    ) {
        if (!isset($login) || !isset($password)) {
            throw new InvalidArgumentException('Neither username or password can be empty!');
        }

        $user = $this->isValidUser($login, $password);
        if (is_null($user)) {
            throw new UserNotFoundException('User not found');
        }

        foreach ($updateUserInfo as $key => $value) {
            $user->set($key, $value);
        }

        $updateTokenInfo['login'] = $login;
        $updateTokenInfo['userid'] = $user->getUserid();
        $jwtData = $jwtWrapper->createJwtData(
            $updateTokenInfo,
            $expires
        );

        $token = $jwtWrapper->generateToken($jwtData);

        $user->set('TOKEN_HASH', sha1($token));
        $this->save($user);

        return $token;
    }
public function createAuthToken ( $ login , $ password , $ jwtWrapper , $ expires = 1200 , $ updateUserInfo = [ ] , $ updateTokenInfo = [ ] ) { if ( ! isset ( $ login ) || ! isset ( $ password ) ) { throw new InvalidArgumentException ( 'Neither username or password can be empty!' ) ; } $ user = $ this -> isValidUser ( $ login , $ password ) ; if ( is_null ( $ user ) ) { throw new UserNotFoundException ( 'User not found' ) ; } foreach ( $ updateUserInfo as $ key => $ value ) { $ user -> set ( $ key , $ value ) ; } $ updateTokenInfo [ 'login' ] = $ login ; $ updateTokenInfo [ 'userid' ] = $ user -> getUserid ( ) ; $ jwtData = $ jwtWrapper -> createJwtData ( $ updateTokenInfo , $ expires ) ; $ token = $ jwtWrapper -> generateToken ( $ jwtData ) ; $ user -> set ( 'TOKEN_HASH' , sha1 ( $ token ) ) ; $ this -> save ( $ user ) ; return $ token ; }
Authenticate a user and create a token if it is valid

@param string $login
@param string $password
@param JwtWrapper $jwtWrapper
@param int $expires
@param array $updateUserInfo
@param array $updateTokenInfo
@return string the TOKEN or false if dont.
@throws UserNotFoundException
@throws \ByJG\Serializer\Exception\InvalidArgumentException
Authenticate a user and create a token if it is valid