Guest User

Untitled

a guest
Jan 28th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. "name": "Unauthorized",
  2. "message": "Your request was made with invalid credentials.",
  3. "code": 0,
  4. "status": 401,
  5. "type": "yii\web\UnauthorizedHttpException"
  6.  
  7. public static function findIdentityByAccessToken($username, $password = null)
  8. {
  9. // throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
  10. //return static::findOne(['username' => $username]);
  11.  
  12. $user = static::findOne(['username' => $username]);
  13. if ($user != null and $user->validatePassword($password)) {
  14. return $user;
  15. } else {
  16. return null;
  17. }
  18. }
  19.  
  20. public function validatePassword($password)
  21. {
  22. $hash = Yii::$app->getSecurity()->generatePasswordHash($password);
  23. return Yii::$app->getSecurity()->validatePassword($password, $this->password_hash);
  24. }
Add Comment
Please, Sign In to add comment