mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding user check fix for AuthComponent::isAuthorized(), and removing comments from Model test (Ticket #2381)
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4833 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
30ea0fb69b
commit
0c43266ba7
2 changed files with 5 additions and 7 deletions
|
@ -330,7 +330,9 @@ class AuthComponent extends Object {
|
||||||
* @return boolean True if $user is authorized, otherwise false
|
* @return boolean True if $user is authorized, otherwise false
|
||||||
*/
|
*/
|
||||||
function isAuthorized(&$controller, $type = null, $user = null) {
|
function isAuthorized(&$controller, $type = null, $user = null) {
|
||||||
if (empty($user)) {
|
if (empty($user) && !$this->user()) {
|
||||||
|
return false;
|
||||||
|
} elseif (empty($user)) {
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
}
|
}
|
||||||
extract($this->__authType($type));
|
extract($this->__authType($type));
|
||||||
|
@ -353,7 +355,7 @@ class AuthComponent extends Object {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'actions':
|
case 'actions':
|
||||||
$valid = $this->Acl->check($this->user(), $this->action());
|
$valid = $this->Acl->check($user, $this->action());
|
||||||
break;
|
break;
|
||||||
case 'objects':
|
case 'objects':
|
||||||
|
|
||||||
|
@ -366,7 +368,7 @@ class AuthComponent extends Object {
|
||||||
if (!isset($this->actionMap[$this->params['action']])) {
|
if (!isset($this->actionMap[$this->params['action']])) {
|
||||||
trigger_error('Auth::startup() - Attempted access of un-mapped action "' . $this->params['action'] . '" in controller "' . $this->params['controller'] . '"', E_USER_WARNING);
|
trigger_error('Auth::startup() - Attempted access of un-mapped action "' . $this->params['action'] . '" in controller "' . $this->params['controller'] . '"', E_USER_WARNING);
|
||||||
} else {
|
} else {
|
||||||
$valid = $this->Acl->check($this->user(), $this->action(':controller'), $this->actionMap[$this->params['action']]);
|
$valid = $this->Acl->check($user, $this->action(':controller'), $this->actionMap[$this->params['action']]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case null:
|
case null:
|
||||||
|
|
|
@ -733,10 +733,6 @@ class ModelTest extends CakeTestCase {
|
||||||
'hasAndBelongsToMany'=>array('Tag'))
|
'hasAndBelongsToMany'=>array('Tag'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// UNCOMMENT THE FOLLOWING LINE TO MAKE TEST SUCCEED:
|
|
||||||
//
|
|
||||||
// $this->Featured->ArticleFeatured->unbindModel(array('belongsTo'=>array('Category')));
|
|
||||||
|
|
||||||
$orderBy = 'ArticleFeatured.id ASC';
|
$orderBy = 'ArticleFeatured.id ASC';
|
||||||
$result = $this->Featured->findAll(null, null, $orderBy, 3);
|
$result = $this->Featured->findAll(null, null, $orderBy, 3);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue