Commit fe826533 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Ajout paramètre pour obtenir l'identité LDAP ou DB éventuelle en priorité.

parent af53e02e
......@@ -45,9 +45,10 @@ abstract class UserAbstract extends \Zend\I18n\View\Helper\AbstractTranslatorHel
/**
* Retourne les données d'identité courante éventuelle.
*
* @param string $preferedKey
* @return mixed
*/
public function getIdentity()
public function getIdentity($preferedKey = 'ldap')
{
if (!$this->getAuthService() || !$this->getAuthService()->hasIdentity()) {
return null;
......@@ -56,12 +57,16 @@ abstract class UserAbstract extends \Zend\I18n\View\Helper\AbstractTranslatorHel
$identity = $this->getAuthService()->getIdentity();
if (is_array($identity)) {
if (isset($identity['db'])) {
$identity = $identity['db'];
$preferedKey = $preferedKey ?: 'ldap';
if (isset($identity[$preferedKey])) {
$identity = $identity[$preferedKey];
}
elseif (isset($identity['ldap'])) {
$identity = $identity['ldap'];
}
elseif (isset($identity['db'])) {
$identity = $identity['db'];
}
else {
throw new \InvalidArgumentException("Données d'identité invalides.");
}
......
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