From cbc7e82bd2b8c32e7780e1bc9bd94b71bc4ef7d4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 2 Jun 2011 21:53:56 -0400 Subject: [PATCH] Fixing issue where Aro nodes would be incorrectly formatted for use with the AclComponent. Fixes #1749 --- lib/Cake/Controller/Component/Auth/ActionsAuthorize.php | 3 ++- lib/Cake/Controller/Component/Auth/BaseAuthorize.php | 6 ++++-- .../Case/Controller/Component/Auth/ActionsAuthorizeTest.php | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php index 4c60326f9..a9247c112 100644 --- a/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php @@ -35,6 +35,7 @@ class ActionsAuthorize extends BaseAuthorize { */ public function authorize($user, CakeRequest $request) { $Acl = $this->_Collection->load('Acl'); + $user = array($this->settings['userModel'] => $user); return $Acl->check($user, $this->action($request)); } -} \ No newline at end of file +} diff --git a/lib/Cake/Controller/Component/Auth/BaseAuthorize.php b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php index f4124920f..232aca9b6 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php @@ -41,6 +41,7 @@ abstract class BaseAuthorize { * - `actionPath` - The path to ACO nodes that contains the nodes for controllers. Used as a prefix * when calling $this->action(); * - `actionMap` - Action -> crud mappings. Used by authorization objects that want to map actions to CRUD roles. + * - `userModel` - Model name that ARO records can be found under. Defaults to 'User'. * * @var array */ @@ -53,7 +54,8 @@ abstract class BaseAuthorize { 'view' => 'read', 'delete' => 'delete', 'remove' => 'delete' - ) + ), + 'userModel' => 'User' ); /** @@ -132,4 +134,4 @@ abstract class BaseAuthorize { } } } -} \ No newline at end of file +} diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php index 10cc865f8..d1caac421 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php @@ -75,7 +75,7 @@ class ActionsAuthorizeTest extends CakeTestCase { ->with($user, '/controllers/Posts/index') ->will($this->returnValue(false)); - $this->assertFalse($this->auth->authorize($user, $request)); + $this->assertFalse($this->auth->authorize($user['User'], $request)); } /** @@ -104,7 +104,7 @@ class ActionsAuthorizeTest extends CakeTestCase { ->with($user, '/controllers/Posts/index') ->will($this->returnValue(true)); - $this->assertTrue($this->auth->authorize($user, $request)); + $this->assertTrue($this->auth->authorize($user['User'], $request)); } /**