Skip to content

Instantly share code, notes, and snippets.

@fatkulnurk
Created July 13, 2018 04:42
Show Gist options
  • Save fatkulnurk/b5202a22acbd5d6a9e7eb77a1bd8da84 to your computer and use it in GitHub Desktop.
Save fatkulnurk/b5202a22acbd5d6a9e7eb77a1bd8da84 to your computer and use it in GitHub Desktop.
/**
* {@inheritdoc}
*/
public static function findIdentity($id)
{
return static::findOne($id);
}
/**
* {@inheritdoc}
*/
public static function findIdentityByAccessToken($token, $type = null)
{
$result = static::findOne(['accessToke'=>$token]);
return new static($result);
}
/**
* Finds user by username
*
* @param string $username
* @return static|null
*/
public static function findByUsername($username)
{
$result = self::find()->where(['username'=>$username])->one();
return new static($result);
}
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getAuthKey()
{
// return $this->authkey;
}
/**
* {@inheritdoc}
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* Validates password
*
* @param string $password password to validate
* @return bool if password provided is valid for current user
*/
public function validatePassword($password)
{
return $this->password == $password;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment