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 ( string $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 findIdentity ( mixed $id ) | ||
| $id | mixed | |
public static function findIdentity($id)
{
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
}
| public static findIdentityByAccessToken ( mixed $token, mixed $type = null ) | ||
| $token | mixed | |
| $type | mixed | |
public static function findIdentityByAccessToken($token, $type = null)
{
foreach (self::$users as $user) {
if ($user['accessToken'] === $token) {
return new static($user);
}
}
return null;
}
| public validateAuthKey ( mixed $authKey ) | ||
| $authKey | mixed | |
public function validateAuthKey($authKey)
{
return $this->authKey === $authKey;
}
Validates password
| public boolean validatePassword ( string $password ) | ||
| $password | string |
Password to validate |
| return | boolean |
If password provided is valid for current user |
|---|---|---|
public function validatePassword($password)
{
return $this->password === $password;
}