Class app\models\User
Inheritance | app\models\User » yii\base\BaseObject |
---|---|
Implements | yii\web\IdentityInterface |
Source Code | https://github.com/yiisoft/yii2-app-basic/blob/master/models/User.php |
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$accessToken | app\models\User | ||
$authKey | app\models\User | ||
$id | app\models\User | ||
$password | app\models\User | ||
$username | app\models\User |
Public Methods
Method | Description | Defined By |
---|---|---|
findByUsername() | Finds user by username | app\models\User |
findIdentity() | app\models\User | |
findIdentityByAccessToken() | app\models\User | |
getAuthKey() | app\models\User | |
getId() | app\models\User | |
validateAuthKey() | app\models\User | |
validatePassword() | Validates password | app\models\User |
Property Details
Method Details
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;
}
public static void findIdentity ( $id ) | ||
$id |
public static function findIdentity($id)
{
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
}
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;
}
public void validateAuthKey ( $authKey ) | ||
$authKey |
public function validateAuthKey($authKey)
{
return $this->authKey === $authKey;
}
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;
}