Skip to content
Snippets Groups Projects
Commit bb1e9370 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

modificaiton uid

parent 232e7639
No related branches found
No related tags found
No related merge requests found
Pipeline #18655 passed
......@@ -63,8 +63,10 @@ class People extends BasePeople implements UserInterface, ProviderInterface
/**
* {@inheritDoc}
*/
public function getUsername()
public function getUsername(?string $attribut = "supannAliasLogin")
{
if ($attribut === 'supannAliasLogin') return $this->supannaliaslogin;
if ($attribut === 'uid') return $this->uid;
return $this->supannaliaslogin;
}
......
......@@ -18,6 +18,12 @@ use ZfcUser\Entity\UserInterface;
*/
class Ldap extends AuthenticationIdentityProvider implements ChainableProvider
{
protected $usernamefield;
public function setUsernamefield(?string $value = null)
{
$this->usernamefield=$value;
}
/**
* {@inheritDoc}
*/
......@@ -50,7 +56,7 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider
}
if ($identity instanceof UserInterface) {
$roles[] = $identity->getUsername();
$roles[] = $identity->getUsername($this->usernamefield);
}
return $roles;
......
......@@ -30,6 +30,8 @@ class LdapServiceFactory implements FactoryInterface
$simpleIdentityProvider->setDefaultRole($config['default_role']);
$simpleIdentityProvider->setAuthenticatedRole($config['authenticated_role']);
$usernamefield = $config['unicaen-auth']['local']['ldap']['username'];
$simpleIdentityProvider->setUsernamefield($usernamefield);
return $simpleIdentityProvider;
}
......
......@@ -44,6 +44,12 @@ class UserContext extends AbstractService implements EventManagerAwareInterface
*/
protected $identityRoles;
private $usernamefield;
public function setUsernamefield(?string $value = null)
{
$this->usernamefield = $value;
}
/**
* @var AuthenticationService
*/
......@@ -132,7 +138,7 @@ class UserContext extends AbstractService implements EventManagerAwareInterface
return $user->getUsername();
}
if ($user = $this->getLdapUser()) {
return $user->getUsername();
return $user->getUsername($this->usenamefield);
}
if ($user = $this->getDbUser()) {
return $user->getUsername();
......
......@@ -32,7 +32,8 @@ class UserContextFactory
// mais c'est impossible pour l'instant car il y a un cycle dans les dépendances entre services qui
// provoque une boucle infinie.
//
$usernamefield = $config['unicaen-auth']['local']['ldap']['username'];
$service->setUsernamefield($usernamefield);
return $service;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment