|
@@ -24,11 +24,20 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
|
|
],
|
|
],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritdoc
|
|
|
|
|
+ */
|
|
|
public static function findIdentity($id)
|
|
public static function findIdentity($id)
|
|
|
{
|
|
{
|
|
|
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
|
|
return isset(self::$users[$id]) ? new static(self::$users[$id]) : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Finds user by username
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $username
|
|
|
|
|
+ * @return static|null
|
|
|
|
|
+ */
|
|
|
public static function findByUsername($username)
|
|
public static function findByUsername($username)
|
|
|
{
|
|
{
|
|
|
foreach (self::$users as $user) {
|
|
foreach (self::$users as $user) {
|
|
@@ -39,21 +48,36 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritdoc
|
|
|
|
|
+ */
|
|
|
public function getId()
|
|
public function getId()
|
|
|
{
|
|
{
|
|
|
return $this->id;
|
|
return $this->id;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritdoc
|
|
|
|
|
+ */
|
|
|
public function getAuthKey()
|
|
public function getAuthKey()
|
|
|
{
|
|
{
|
|
|
return $this->authKey;
|
|
return $this->authKey;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @inheritdoc
|
|
|
|
|
+ */
|
|
|
public function validateAuthKey($authKey)
|
|
public function validateAuthKey($authKey)
|
|
|
{
|
|
{
|
|
|
return $this->authKey === $authKey;
|
|
return $this->authKey === $authKey;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Validates password
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $password password to validate
|
|
|
|
|
+ * @return bool if password provided is valid for current user
|
|
|
|
|
+ */
|
|
|
public function validatePassword($password)
|
|
public function validatePassword($password)
|
|
|
{
|
|
{
|
|
|
return $this->password === $password;
|
|
return $this->password === $password;
|