common/modules/api_v1/v1/controllers/UserController.php
/**
     * Authenticates user by provided username and password.
     * In case password is emtpy we assume that username
     * contains access token.
     *
     * @return mixed
     */
Authenticates user by provided username and password.
In case password is emtpy we assume that username
contains access token.

@return mixed
Authenticates user by provided username and password . In case password is emtpy we assume that username contains access token . @return mixed
public function actionAuth()
    {
        $request = Yii::$app->request;
        $response = Yii::$app->response;
        $username = $request->post('username', null);
        $password = $request->post('password', null);
        if ($password !== null) {
            $user = User::findByEmail($username);
            if ($user && !$user->validatePassword($password)) {
                $user = null;
            }
        } else {
            $user = User::findIdentityByAccessToken($username);
        }
        if ($user != null) {
            $identity = [
                'id' => $user->id,
                'email' => $user->email,
                'roles' => $user->getRoles(true)
            ];
            return [
                'success' => true,
                'identity' => $identity
            ];
        } else {
            $response->setStatusCode(400);
            return [
                'success' => false,
                'message' => 'Authentication failed.'
            ];
        }
    }
public function actionAuth ( ) { $ request = Yii :: $ app -> request ; $ response = Yii :: $ app -> response ; $ username = $ request -> post ( 'username' , null ) ; $ password = $ request -> post ( 'password' , null ) ; if ( $ password !== null ) { $ user = User :: findByEmail ( $ username ) ; if ( $ user && ! $ user -> validatePassword ( $ password ) ) { $ user = null ; } } else { $ user = User :: findIdentityByAccessToken ( $ username ) ; } if ( $ user != null ) { $ identity = [ 'id' => $ user -> id , 'email' => $ user -> email , 'roles' => $ user -> getRoles ( true ) ] ; return [ 'success' => true , 'identity' => $ identity ] ; } else { $ response -> setStatusCode ( 400 ) ; return [ 'success' => false , 'message' => 'Authentication failed.' ] ; } }
Authenticates user by provided username and password.
Authenticates user by provided username and password .