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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
30907b61
Commit
30907b61
authored
Sep 13, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #826: cleaned up User::getReturnUrl().
parent
6c6cb3cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
User.php
framework/yii/web/User.php
+18
-3
No files found.
framework/yii/web/User.php
View file @
30907b61
...
...
@@ -10,6 +10,7 @@ namespace yii\web;
use
Yii
;
use
yii\base\Component
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidParamException
;
/**
* User is the class for the "user" application component that manages the user authentication status.
...
...
@@ -255,20 +256,34 @@ class User extends Component
* This property is usually used by the login action. If the login is successful,
* the action should read this property and use it to redirect the user browser.
* @param string|array $defaultUrl the default return URL in case it was not set previously.
* If this is null
, it means
[[Application::homeUrl]] will be redirected to.
* Please refer to [[
\yii\helpers\Html::url()]] on acceptable URL formats
.
* If this is null
and the return URL was not set previously,
[[Application::homeUrl]] will be redirected to.
* Please refer to [[
setReturnUrl()]] on accepted format of the URL
.
* @return string the URL that the user should be redirected to after login.
* @see loginRequired
*/
public
function
getReturnUrl
(
$defaultUrl
=
null
)
{
$url
=
Yii
::
$app
->
getSession
()
->
get
(
$this
->
returnUrlVar
,
$defaultUrl
);
if
(
is_array
(
$url
))
{
if
(
isset
(
$url
[
0
]))
{
$route
=
array_shift
(
$url
);
return
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
$route
,
$url
);
}
else
{
$url
=
null
;
}
}
return
$url
===
null
?
Yii
::
$app
->
getHomeUrl
()
:
$url
;
}
/**
* @param string|array $url the URL that the user should be redirected to after login.
* Please refer to [[\yii\helpers\Html::url()]] on acceptable URL formats.
* If an array is given, [[UrlManager::createUrl()]] will be called to create the corresponding URL.
* The first element of the array should be the route, and the rest of
* the name-value pairs are GET parameters used to construct the URL. For example,
*
* ~~~
* array('admin/index', 'ref' => 1)
* ~~~
*/
public
function
setReturnUrl
(
$url
)
{
...
...
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