1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/aeneria_ynh.git synced 2024-09-03 18:06:15 +02:00

upadte ldap patch

This commit is contained in:
Simon Mellerin 2024-01-07 19:38:43 +01:00
parent 0589491e11
commit 3e0304fe5a

View file

@ -122,14 +122,14 @@ index 00000000..eb8b1149
+ $email = $entry->getAttribute('mail'); + $email = $entry->getAttribute('mail');
+ +
+ // Dans le cadre de la connexion LDAP Yunohost, + // Dans le cadre de la connexion LDAP Yunohost,
+ // on cherche l'utilisateur par son id et son mail, + // on cherche l'utilisateur par son mail.
+ // puis on l'enregistre uniquement avec son id. + //
+ $user = $this->userRepository->findOneBy(['username' => [...$email, $identifier]]); + $user = $this->userRepository->findOneBy(['username' => $email]);
+ +
+ // Si l'utilisateur n'existe pas enore, on le crée. + // Si l'utilisateur n'existe pas encore, on le crée.
+ if (!$user) { + if (!$user) {
+ $user = (new User()) + $user = (new User())
+ ->setUsername($identifier) + ->setUsername(\reset($email))
+ ->setPassword(\random_bytes(32)) + ->setPassword(\random_bytes(32))
+ ->setActive(true) + ->setActive(true)
+ ->setUpdatedAt(new \DateTimeImmutable()) + ->setUpdatedAt(new \DateTimeImmutable())
@ -139,8 +139,8 @@ index 00000000..eb8b1149
+ $this->entityManager->flush(); + $this->entityManager->flush();
+ } + }
+ +
+ return $user->setUsername($identifier) + return $user->setUsername(\reset($email))
+ ->setEmail(\reset($email)) + ->setIdentifier($identifier)
+ ; + ;
+ } + }
+} +}