Commit 8a416dff authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Correction bug : test d'activation manquant dans les adapteurs Db et Ldap.

parent 1f0c2a2a
Loading
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Interop\Container\ContainerInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface;
use UnicaenApp\ServiceManager\ServiceLocatorAwareTrait;
use UnicaenAuth\Options\ModuleOptions;
use UnicaenAuth\Options\Traits\ModuleOptionsAwareTrait;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\Crypt\Password\Bcrypt;
use Zend\EventManager\EventInterface;
@@ -24,6 +25,8 @@ use ZfcUser\Mapper\UserInterface as UserMapperInterface;
 */
class Db extends AbstractAdapter implements ServiceLocatorAwareInterface
{
    use ModuleOptionsAwareTrait;

    const TYPE = 'db';

    /**
@@ -106,6 +109,10 @@ class Db extends AbstractAdapter implements ServiceLocatorAwareInterface
            return;
        }

        if (! $this->isEnabled()) {
            return;
        }

        $identity   = $e->getRequest()->getPost()->get('identity');
        $credential = $e->getRequest()->getPost()->get('credential');
        $credential = $this->preProcessCredential($credential);
@@ -169,6 +176,20 @@ class Db extends AbstractAdapter implements ServiceLocatorAwareInterface
            ->setMessages(array('Authentication successful.'));
    }

    /**
     * @return bool
     */
    protected function isEnabled()
    {
        $config = $this->moduleOptions->getDb();

        if (isset($config['enabled'])) {
            return (bool) $config['enabled'];
        }

        return false;
    }

    protected function updateUserPasswordHash(UserInterface $userObject, $password, Bcrypt $bcrypt)
    {
        $hash = explode('$', $userObject->getPassword());
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,12 @@ class DbAdapterFactory
        $adapter = new Db();
        $adapter->setStorage(new Session(Db::class));

        $options = array_merge(
            $container->get('zfcuser_module_options')->toArray(),
            $container->get('unicaen-auth_module_options')->toArray());
        $moduleOptions = new ModuleOptions($options);
        $adapter->setModuleOptions($moduleOptions);

        $substitut = $moduleOptions->getDb()['type'] ?? null;
        if ($substitut !== null) {
            $adapter->setType($substitut);
+18 −0
Original line number Diff line number Diff line
@@ -114,6 +114,10 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface
            return;
        }

        if (! $this->isEnabled()) {
            return;
        }

        $username   = $e->getRequest()->getPost()->get('identity');
        $credential = $e->getRequest()->getPost()->get('credential');

@@ -159,6 +163,20 @@ class Ldap extends AbstractAdapter implements EventManagerAwareInterface
        $this->userService->userAuthenticated($ldapPeople);
    }

    /**
     * @return bool
     */
    protected function isEnabled()
    {
        $config = $this->moduleOptions->getLdap();

        if (isset($config['enabled'])) {
            return (bool) $config['enabled'];
        }

        return false;
    }

    /**
     * Extrait le loginUsurpateur et le loginUsurpé si l'identifiant spécifé est de la forme
     * "loginUsurpateur=loginUsurpé".