diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 778eb5671..eab5deebc 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -776,6 +776,10 @@ class AuthComponent extends Component { unset($config[AuthComponent::ALL]); } foreach ($config as $class => $settings) { + if (!empty($settings['className'])) { + $class = $settings['className']; + unset($settings['className']); + } list($plugin, $class) = pluginSplit($class, true); $className = $class . 'Authenticate'; App::uses($className, $plugin . 'Controller/Component/Auth'); diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index e76f65c32..5c061d938 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -590,6 +590,27 @@ class AuthComponentTest extends CakeTestCase { $this->assertEquals('AuthUser', $result->settings['userModel']); } +/** + * test defining the same Authenticate object but with different password hashers + * + * @return void + */ + public function testSameAuthenticateWithDifferentHashers() { + $this->Controller->Auth->authenticate = array( + 'FormSimple' => array('className' => 'Form', 'passwordHasher' => 'Simple'), + 'FormBlowfish' => array('className' => 'Form', 'passwordHasher' => 'Blowfish'), + ); + + $objects = $this->Controller->Auth->constructAuthenticate(); + $this->assertEquals(2, count($objects)); + + $this->assertInstanceOf('FormAuthenticate', $objects[0]); + $this->assertInstanceOf('FormAuthenticate', $objects[1]); + + $this->assertInstanceOf('SimplePasswordHasher', $objects[0]->passwordHasher()); + $this->assertInstanceOf('BlowfishPasswordHasher', $objects[1]->passwordHasher()); + } + /** * Tests that deny always takes precedence over allow *