updating Auth component

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5419 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-07-09 04:38:58 +00:00
parent a1019dfad3
commit 49817ea42d

View file

@ -300,34 +300,38 @@ class AuthComponent extends Object {
} }
} }
} }
extract($this->__authType($this->authorize));
if($type !== 'controller') { if($this->authorize) {
if(isset($controller->Acl)) { extract($this->__authType($this->authorize));
$this->Acl =& $controller->Acl; if($type !== 'controller') {
if($type == 'model') { if(isset($controller->Acl)) {
if(!isset($object)) { $this->Acl =& $controller->Acl;
if (isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass})) { if($type == 'model') {
$object = $controller->modelClass; if(!isset($object)) {
} elseif (!empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]})) { if (isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass})) {
$object = $controller->uses[0]; $object = $controller->modelClass;
} else { } elseif (!empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]})) {
$object = $this->objectModel; $object = $controller->uses[0];
} else {
$object = $this->objectModel;
}
} }
} }
} if ($this->isAuthorized($type, null, $object)) {
if ($this->isAuthorized($type, null, $object)) { return true;
return true; }
} else {
trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING);
} }
} else { } else {
trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING); if (method_exists($controller, 'isAuthorized')) {
} if($controller->isAuthorized()) {
} else { return true;
if (method_exists($controller, 'isAuthorized')) { }
if($controller->isAuthorized()) {
return true;
} }
} }
} }
$this->Session->setFlash($this->authError); $this->Session->setFlash($this->authError);
$controller->redirect($controller->referer(), null, true); $controller->redirect($controller->referer(), null, true);
return false; return false;