Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
94a9087b
Commit
94a9087b
authored
Mar 03, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed `User::loginByToken()` to `loginByAccessToken()`.
parent
a8c7d36c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
Controller.php
framework/rest/Controller.php
+1
-1
User.php
framework/web/User.php
+9
-1
No files found.
framework/rest/Controller.php
View file @
94a9087b
...
...
@@ -181,7 +181,7 @@ class Controller extends \yii\web\Controller
}
}
if
(
empty
(
$accessToken
)
||
!
Yii
::
$app
->
getUser
()
->
loginByToken
(
$accessToken
))
{
if
(
empty
(
$accessToken
)
||
!
Yii
::
$app
->
getUser
()
->
loginBy
Access
Token
(
$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.'
);
}
...
...
framework/web/User.php
View file @
94a9087b
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment