Fixing issue where Aro nodes would be incorrectly formatted for use

with the AclComponent.  Fixes #1749
This commit is contained in:
mark_story 2011-06-02 21:53:56 -04:00
parent 2650bd4639
commit cbc7e82bd2
3 changed files with 8 additions and 5 deletions

View file

@ -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));
}
}
}

View file

@ -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 {
}
}
}
}
}

View file

@ -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));
}
/**