mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Auth model authorization will pass user, controller, action as parameters to the model's isAuthorized method
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5437 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d09a59c5df
commit
87bddd81f0
1 changed files with 2 additions and 9 deletions
|
@ -317,8 +317,6 @@ class AuthComponent extends Object {
|
|||
$object = $controller->modelClass;
|
||||
} elseif (!empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]})) {
|
||||
$object = $controller->uses[0];
|
||||
} else {
|
||||
$object = $this->objectModel;
|
||||
}
|
||||
}
|
||||
if ($this->isAuthorized($type, null, $object)) {
|
||||
|
@ -403,9 +401,7 @@ class AuthComponent extends Object {
|
|||
}
|
||||
$model = $this->getModel($object);
|
||||
if (method_exists($model, 'isAuthorized')) {
|
||||
if($model->isAuthorized($user)) {
|
||||
return true;
|
||||
}
|
||||
$valid = $model->isAuthorized($user, $this->action(':controller'), $this->action(':action'));
|
||||
} else if($model){
|
||||
trigger_error(__(sprintf('%s::isAuthorized() is not defined.', $model), true), E_USER_WARNING);
|
||||
}
|
||||
|
@ -430,13 +426,10 @@ class AuthComponent extends Object {
|
|||
if (empty($auth)) {
|
||||
$auth = $this->authorize;
|
||||
}
|
||||
$object = null;
|
||||
$object = $this->objectModel;
|
||||
if (is_array($auth)) {
|
||||
$type = key($auth);
|
||||
$object = $auth[$type];
|
||||
if (isset($auth[0])) {
|
||||
$assoc = $auth[0];
|
||||
}
|
||||
} else {
|
||||
$type = $auth;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue