Skip to content
Permalink
Browse files

Use array key as alias for Authorize and Authenticate providers

  • Loading branch information...
Walther Lalk
Walther Lalk committed Sep 1, 2014
1 parent c2452a7 commit a250027bb2eea2c57a75ba2354d9f45a8ee15110
Showing with 10 additions and 14 deletions.
  1. +10 −14 src/Controller/Component/AuthComponent.php
@@ -492,20 +492,20 @@ public function constructAuthorize() {
$global = $authorize[AuthComponent::ALL];
unset($authorize[AuthComponent::ALL]);
}
foreach ($authorize as $class => $config) {
foreach ($authorize as $alias => $config) {
if (!empty($config['className'])) {
$class = $config['className'];
unset($config['className']);
} else {
$class = $alias;
}
$className = App::className($class, 'Auth', 'Authorize');
if (!class_exists($className)) {
throw new Exception(sprintf('Authorization adapter "%s" was not found.', $class));
}
if (!method_exists($className, 'authorize')) {
throw new Exception('Authorization objects must implement an authorize() method.');
}
if (!empty($config['alias'])) {
$alias = $config['alias'];
unset($config['alias']);
} else {
$alias = $className;
}
$config = (array)$config + $global;
$this->_authorizeObjects[$alias] = new $className($this->_registry, $config);
}
@@ -749,10 +749,12 @@ public function constructAuthenticate() {
$global = $authenticate[AuthComponent::ALL];
unset($authenticate[AuthComponent::ALL]);
}
foreach ($authenticate as $class => $config) {
foreach ($authenticate as $alias => $config) {
if (!empty($config['className'])) {
$class = $config['className'];
unset($config['className']);
} else {
$class = $alias;
}
$className = App::className($class, 'Auth', 'Authenticate');
if (!class_exists($className)) {
@@ -761,12 +763,6 @@ public function constructAuthenticate() {
if (!method_exists($className, 'authenticate')) {
throw new Exception('Authentication objects must implement an authenticate() method.');
}
if (!empty($config['alias'])) {
$alias = $config['alias'];
unset($config['alias']);
} else {
$alias = $className;
}
$config = array_merge($global, (array)$config);
$this->_authenticateObjects[$alias] = new $className($this->_registry, $config);
}

0 comments on commit a250027

Please sign in to comment.
You can’t perform that action at this time.