Commit 94a9087b by Qiang Xue

Renamed `User::loginByToken()` to `loginByAccessToken()`.

parent a8c7d36c
......@@ -181,7 +181,7 @@ class Controller extends \yii\web\Controller
}
}
if (empty($accessToken) || !Yii::$app->getUser()->loginByToken($accessToken)) {
if (empty($accessToken) || !Yii::$app->getUser()->loginByAccessToken($accessToken)) {
Yii::$app->getResponse()->getHeaders()->set("WWW-Authenticate', '{$this->authType} realm=\"{$this->authRealm}\"");
throw new UnauthorizedHttpException(empty($accessToken) ? 'Access token required.' : 'You are requesting with an invalid access token.');
}
......
......@@ -209,7 +209,15 @@ class User extends Component
return !$this->getIsGuest();
}
public function loginByToken($token)
/**
* Logs in a user by the given access token.
* Note that unlike [[login()]], this method will NOT start a session to remember the user authentication status.
* Also if the access token is invalid, the user will remain as a guest.
* @param string $token the access token
* @return IdentityInterface the identity associated with the given access token. Null is returned if
* the access token is invalid.
*/
public function loginByAccessToken($token)
{
/** @var IdentityInterface $class */
$class = $this->identityClass;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment