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
7b374c41
Commit
7b374c41
authored
Apr 25, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3230: Added `yii\filters\AccessControl::user` to support access control…
Fixes #3230: Added `yii\filters\AccessControl::user` to support access control with different actors
parent
cc217e7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
AccessControl.php
framework/filters/AccessControl.php
+7
-1
No files found.
framework/CHANGELOG.md
View file @
7b374c41
...
...
@@ -30,6 +30,7 @@ Yii Framework 2 Change Log
-
Enh #3132:
`yii\rbac\PhpManager`
now supports more compact data file format (qiangxue)
-
Enh #3154: Added validation error display for
`GridView`
filters (ivan-kolmychek)
-
Enh #3222: Added
`useTablePrefix`
option to the model generator for Gii (horizons2)
-
Enh #3230: Added
`yii\filters\AccessControl::user`
to support access control with different actors (qiangxue)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
-
Enh: Added
`yii\web\UrlManager::addRules()`
to simplify adding new URL rules (qiangxue)
...
...
framework/filters/AccessControl.php
View file @
7b374c41
...
...
@@ -10,6 +10,7 @@ namespace yii\filters;
use
Yii
;
use
yii\base\Action
;
use
yii\base\ActionFilter
;
use
yii\di\Instance
;
use
yii\web\User
;
use
yii\web\ForbiddenHttpException
;
...
...
@@ -56,6 +57,10 @@ use yii\web\ForbiddenHttpException;
class
AccessControl
extends
ActionFilter
{
/**
* @var User|string the user object representing the authentication status or the ID of the user application component.
*/
public
$user
=
'user'
;
/**
* @var callable a callback that will be called if the access should be denied
* to the current user. If not set, [[denyAccess()]] will be called.
*
...
...
@@ -89,6 +94,7 @@ class AccessControl extends ActionFilter
public
function
init
()
{
parent
::
init
();
$this
->
user
=
Instance
::
ensure
(
$this
->
user
,
User
::
className
());
foreach
(
$this
->
rules
as
$i
=>
$rule
)
{
if
(
is_array
(
$rule
))
{
$this
->
rules
[
$i
]
=
Yii
::
createObject
(
array_merge
(
$this
->
ruleConfig
,
$rule
));
...
...
@@ -104,7 +110,7 @@ class AccessControl extends ActionFilter
*/
public
function
beforeAction
(
$action
)
{
$user
=
Yii
::
$app
->
getUser
()
;
$user
=
$this
->
user
;
$request
=
Yii
::
$app
->
getRequest
();
/** @var AccessRule $rule */
foreach
(
$this
->
rules
as
$rule
)
{
...
...
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