Commit b15b0e90 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Levée d'un événement lors des erreurs d'authentification.

parent 56b58530
......@@ -5,9 +5,12 @@ use UnicaenAuth\Options\ModuleOptions;
use Zend\Authentication\Exception\UnexpectedValueException;
use Zend\Authentication\Result as AuthenticationResult;
use Zend\Authentication\Adapter\Ldap as LdapAuthAdapter;
use Zend\Authentication\Result;
use Zend\EventManager\Event;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\Ldap\Exception\LdapException;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use ZfcUser\Authentication\Adapter\AbstractAdapter;
......@@ -110,7 +113,22 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
}
// LDAP auth
/** @var Result $result */
$result = $this->getLdapAuthAdapter()->setUsername($username)->setPassword($credential)->authenticate();
if ($result && count($result->getMessages())) {
// Obtenir le message LDAP
// $msg = preg_replace('/\[0x\d* \((.*)\):/','$1', $event->getParam('result')->getMessages()[1]);
$eventClasse = new Event('authentication.ldap.error');
$eventClasse->setTarget($this)->setParams([
'result' => $result
]);
$this->getEventManager()->trigger($eventClasse);
}
$success = $result->isValid();
// verif existence du login usurpé
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment