Class app\models\User

Inheritanceapp\models\User » yii\base\BaseObject
Implementsyii\web\IdentityInterface
Source Code https://github.com/yiisoft/yii2-app-basic/blob/master/models/User.php

Property Details

Hide inherited properties

$accessToken public property
public $accessToken null
$authKey public property
public $authKey null
$id public property
public $id null
$password public property
public $password null
$username public property
public $username null

Method Details

Hide inherited methods

findByUsername() public static method

Finds user by username

public static static|null findByUsername ( $username )
$username string

                public static function findByUsername($username)
{
    foreach (self::$users as $user) {
        if (strcasecmp($user['username'], $username) === 0) {
            return new static($user);
        }
    }
    return null;
}

            
findIdentity() public static method

public static void findIdentity ( $id )
$id

                public static function findIdentity($id)
{
    return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
}

            
findIdentityByAccessToken() public static method

public static void findIdentityByAccessToken ( $token, $type null )
$token
$type

                public static function findIdentityByAccessToken($token, $type = null)
{
    foreach (self::$users as $user) {
        if ($user['accessToken'] === $token) {
            return new static($user);
        }
    }
    return null;
}

            
getAuthKey() public method

public void getAuthKey ( )

                public function getAuthKey()
{
    return $this->authKey;
}

            
getId() public method

public void getId ( )

                public function getId()
{
    return $this->id;
}

            
validateAuthKey() public method

public void validateAuthKey ( $authKey )
$authKey

                public function validateAuthKey($authKey)
{
    return $this->authKey === $authKey;
}

            
validatePassword() public method

Validates password

public boolean validatePassword ( $password )
$password string

Password to validate

return boolean

If password provided is valid for current user

                public function validatePassword($password)
{
    return $this->password === $password;
}