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
e87220be
Commit
e87220be
authored
Feb 09, 2014
by
Dilip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Request.php
parent
2026eb85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
Request.php
framework/web/Request.php
+7
-7
No files found.
framework/web/Request.php
View file @
e87220be
...
...
@@ -95,10 +95,10 @@ class Request extends \yii\base\Request
* from the same application. If not, a 400 HTTP exception will be raised.
*
* Note, this feature requires that the user client accepts cookie. Also, to use this feature,
* forms submitted via POST method must contain a hidden input whose name is specified by [[csrf
Var
]].
* forms submitted via POST method must contain a hidden input whose name is specified by [[csrf
Param
]].
* You may use [[\yii\web\Html::beginForm()]] to generate his hidden input.
*
* In JavaScript, you may get the values of [[csrf
Var]] and [[csrfToken]] via `yii.getCsrfVar
()` and
* In JavaScript, you may get the values of [[csrf
Param]] and [[csrfToken]] via `yii.getCsrfParam
()` and
* `yii.getCsrfToken()`, respectively. The [[\yii\web\YiiAsset]] asset must be registered.
*
* @see Controller::enableCsrfValidation
...
...
@@ -109,7 +109,7 @@ class Request extends \yii\base\Request
* @var string the name of the token used to prevent CSRF. Defaults to '_csrf'.
* This property is used only when [[enableCsrfValidation]] is true.
*/
public
$csrf
Var
=
'_csrf'
;
public
$csrf
Param
=
'_csrf'
;
/**
* @var array the configuration of the CSRF cookie. This property is used only when [[enableCsrfValidation]] is true.
* @see Cookie
...
...
@@ -1103,7 +1103,7 @@ class Request extends \yii\base\Request
public
function
getRawCsrfToken
()
{
if
(
$this
->
_csrfCookie
===
null
)
{
$this
->
_csrfCookie
=
$this
->
getCookies
()
->
get
(
$this
->
csrf
Var
);
$this
->
_csrfCookie
=
$this
->
getCookies
()
->
get
(
$this
->
csrf
Param
);
if
(
$this
->
_csrfCookie
===
null
)
{
$this
->
_csrfCookie
=
$this
->
createCsrfCookie
();
Yii
::
$app
->
getResponse
()
->
getCookies
()
->
add
(
$this
->
_csrfCookie
);
...
...
@@ -1175,7 +1175,7 @@ class Request extends \yii\base\Request
protected
function
createCsrfCookie
()
{
$options
=
$this
->
csrfCookie
;
$options
[
'name'
]
=
$this
->
csrf
Var
;
$options
[
'name'
]
=
$this
->
csrf
Param
;
$options
[
'value'
]
=
Security
::
generateRandomKey
();
return
new
Cookie
(
$options
);
}
...
...
@@ -1194,8 +1194,8 @@ class Request extends \yii\base\Request
if
(
!
$this
->
enableCsrfValidation
||
in_array
(
$method
,
[
'GET'
,
'HEAD'
,
'OPTIONS'
],
true
))
{
return
true
;
}
$trueToken
=
$this
->
getCookies
()
->
getValue
(
$this
->
csrf
Var
);
$token
=
$this
->
getBodyParam
(
$this
->
csrf
Var
);
$trueToken
=
$this
->
getCookies
()
->
getValue
(
$this
->
csrf
Param
);
$token
=
$this
->
getBodyParam
(
$this
->
csrf
Param
);
return
$this
->
validateCsrfTokenInternal
(
$token
,
$trueToken
)
||
$this
->
validateCsrfTokenInternal
(
$this
->
getCsrfTokenFromHeader
(),
$trueToken
);
}
...
...
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