diff --git a/Module.php b/Module.php index c823b63..a3f2fba 100644 --- a/Module.php +++ b/Module.php @@ -16,11 +16,9 @@ class Module implements AutoloaderProviderInterface, ConfigProviderInterface { - public function getConfig() - { - return include __DIR__ . '/config/module.config.php'; - } - + /** + * {@inheritDoc} + */ public function getAutoloaderConfig() { return array( @@ -32,6 +30,19 @@ public function getAutoloaderConfig() ); } + /** + * {@inheritDoc} + */ + public function getConfig() + { + return include __DIR__ . '/config/module.config.php'; + } + + /** + * Get the Liquibase path + * + * @return string + */ public function getLiquibasePath() { return __DIR__ . '/liquibase/changelog.xml'; diff --git a/config/baconuser.global.php.dist b/config/baconuser.global.php.dist index 3f32546..0c69e6a 100644 --- a/config/baconuser.global.php.dist +++ b/config/baconuser.global.php.dist @@ -1,6 +1,21 @@ array( + // User settings + 'user' => array( + // Enable or disable the username field for users + 'enable_username' => true, + + // Enable or disable the user state + 'enable_user_state' => true, + + // Default user state (the state must be in allowed_login_states array) + 'default_user_state' => 1, + + // The allowed login states + 'allowed_login_states' => array(null, 1) + ), + // Password settings 'password' => array( // This is a Zend\ServiceManager compatible configuration containing diff --git a/src/BaconUser/Password/Factory/BcryptFactory.php b/src/BaconUser/Password/Factory/BcryptFactory.php index b034a60..4bbaf77 100644 --- a/src/BaconUser/Password/Factory/BcryptFactory.php +++ b/src/BaconUser/Password/Factory/BcryptFactory.php @@ -28,14 +28,9 @@ class BcryptFactory implements FactoryInterface */ public function createService(ServiceLocatorInterface $serviceLocator) { + $config = $serviceLocator->getServiceLocator()->get('BaconUser\Config'); $bcrypt = new Bcrypt(); - if ($serviceLocator instanceof AbstractPluginManager) { - $config = $serviceLocator->getServiceLocator()->get('BaconUser\Config'); - } else { - $config = $serviceLocator->get('BaconUser\Config'); - } - if (isset($config['password']['bcrypt'])) { $config = $config['password']['bcrypt']; diff --git a/src/BaconUser/Password/HandlerAggregate.php b/src/BaconUser/Password/HandlerAggregate.php index 653e7de..6c55ffc 100644 --- a/src/BaconUser/Password/HandlerAggregate.php +++ b/src/BaconUser/Password/HandlerAggregate.php @@ -13,7 +13,7 @@ use BaconUser\Password\Options\PasswordHandlerAggregateOptionsInterface; /** - * Aggregate password handler for using multiple hashing methods parallely. + * Aggregate password handler for using multiple hashing methods in parallel. */ class HandlerAggregate implements HandlerInterface { @@ -87,7 +87,7 @@ public function shouldRehash($hash) $handler = $this->getHandlerByHash($hash); if ($handler === null) { - // Hash is not uspported by any method, migration recommended. + // Hash is not supported by any method, migration recommended. return true; } @@ -107,7 +107,7 @@ public function shouldRehash($hash) } /** - * @return HashManager + * @return HandlerManager */ public function getHandlerManager() { @@ -156,11 +156,11 @@ public function setOptions(PasswordHandlerAggregateOptionsInterface $options) */ protected function getHandlerByName($hashingMethod) { - if (!isset($this->hashCache[$hashingMethod])) { - $this->hashCache[$hashingMethod] = $this->getHandlerManager()->get($hashingMethod); + if (!isset($this->handlerCache[$hashingMethod])) { + $this->handlerCache[$hashingMethod] = $this->getHandlerManager()->get($hashingMethod); } - return $this->hashCache[$hashingMethod]; + return $this->handlerCache[$hashingMethod]; } /** diff --git a/src/BaconUser/Password/HandlerInterface.php b/src/BaconUser/Password/HandlerInterface.php index 5e0d215..7c7deae 100644 --- a/src/BaconUser/Password/HandlerInterface.php +++ b/src/BaconUser/Password/HandlerInterface.php @@ -45,7 +45,7 @@ public function compare($password, $hash); * * This is used primarily by the authentication adapter, which will verify * whether it should re-hash the plain-text password. This is useful if you - * are migrating to a more secure algorythm, or when the parameters for your + * are migrating to a more secure algorithm, or when the parameters for your * current hash changed. * * @param string $hash diff --git a/src/BaconUser/Password/HandlerManager.php b/src/BaconUser/Password/HandlerManager.php index 2bcfc76..251d814 100644 --- a/src/BaconUser/Password/HandlerManager.php +++ b/src/BaconUser/Password/HandlerManager.php @@ -44,7 +44,7 @@ class HandlerManager extends AbstractPluginManager * @see AbstractPluginManager::validatePlugin() * @param mixed $plugin * @return void - * @throws RuntimeException + * @throws Exception\RuntimeException */ public function validatePlugin($plugin) { diff --git a/src/BaconUser/Password/Options/PasswordHandlerAggregateOptions.php b/src/BaconUser/Password/Options/PasswordHandlerAggregateOptions.php index 18e5754..1ece44a 100644 --- a/src/BaconUser/Password/Options/PasswordHandlerAggregateOptions.php +++ b/src/BaconUser/Password/Options/PasswordHandlerAggregateOptions.php @@ -45,7 +45,7 @@ public function getHashingMethods() /** * @param array $hashingMethods - * @return HandlerAggregate + * @return \BaconUser\Password\HandlerAggregate */ public function setHashingMethods(array $hashingMethods) { @@ -63,7 +63,7 @@ public function getDefaultHashingMethod() /** * @param string $defaultHashingMethod - * @return HandlerAggregate + * @return \BaconUser\Password\HandlerAggregate */ public function setDefaultHashingMethod($defaultHashingMethod) { @@ -81,7 +81,7 @@ public function getMigrateToDefaultHashingMethod() /** * @param bool $migrateToDefaultHashingMethod - * @return HandlerAggregate + * @return \BaconUser\Password\HandlerAggregate */ public function setMigrateToDefaultHashingMethod($migrateToDefaultHashingMethod) { diff --git a/tests/BaconUserTest/Password/Factory/BcryptFactoryTest.php b/tests/BaconUserTest/Password/Factory/BcryptFactoryTest.php index d0b400c..e23e9ab 100644 --- a/tests/BaconUserTest/Password/Factory/BcryptFactoryTest.php +++ b/tests/BaconUserTest/Password/Factory/BcryptFactoryTest.php @@ -18,15 +18,6 @@ */ class BcryptFactoryTest extends TestCase { - public function testFactoryFromServiceLocator() - { - $locator = new ServiceManager(); - $locator->setService('BaconUser\Config', array()); - - $factory = new BcryptFactory(); - $this->assertInstanceOf('BaconUser\Password\Bcrypt', $factory->createService($locator)); - } - public function testFactoryFromPluginManager() { $locator = new ServiceManager(); @@ -46,7 +37,12 @@ public function testFactoryWithCostSet() $locator = new ServiceManager(); $locator->setService('BaconUser\Config', array('password' => array('bcrypt' => array('cost' => 4)))); + $pluginManager = $this->getMock('Zend\ServiceManager\AbstractPluginManager'); + $pluginManager->expects($this->once()) + ->method('getServiceLocator') + ->will($this->returnValue($locator)); + $factory = new BcryptFactory(); - $this->assertInstanceOf('BaconUser\Password\Bcrypt', $factory->createService($locator)); + $this->assertInstanceOf('BaconUser\Password\Bcrypt', $factory->createService($pluginManager)); } }