wip-feat: reduces env vars, adds getting-started page

This commit is contained in:
2025-05-15 23:25:12 -05:00
parent ce6fda257b
commit 5d5d66bd79
22 changed files with 500 additions and 62 deletions

View File

@@ -11,6 +11,8 @@
namespace App\User\Framework\Security;
use App\User\Action\Command\RegisterLdapUserCommand;
use App\User\Action\Handler\RegisterLdapUserHandler;
use App\User\Framework\Entity\User;
use App\User\Framework\Repository\UserRepository;
use Symfony\Component\Ldap\Entry;
@@ -45,6 +47,7 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
private string $displayNameAttribute;
public function __construct(
private RegisterLdapUserHandler $registerLdapUserHandler,
private UserRepository $userRepository,
private LdapInterface $ldap,
private string $baseDn,
@@ -159,21 +162,24 @@ class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterfa
$dbUser = $this->getDbUser($identifier, $entry);
if (null === $dbUser) {
$dbUser = new User();
$dbUser->setPassword("test");
return $this->registerLdapUserHandler->handle(new RegisterLdapUserCommand(
name:$this->getAttributeValue($entry, $this->displayNameAttribute)[0] ?? null,
email:$this->getAttributeValue($entry, $this->emailAttribute)[0] ?? null,
username:$this->getAttributeValue($entry, $this->usernameAttribute) ?? null,
password: uniqid(),
))->user;
} else {
$dbUser
->setName($this->getAttributeValue($entry, $this->displayNameAttribute)[0] ?? null)
->setEmail($this->getAttributeValue($entry, $this->emailAttribute)[0] ?? null)
->setUsername($this->getAttributeValue($entry, $this->usernameAttribute) ?? null);
$this->userRepository->getEntityManager()->flush();
}
$dbUser
->setName( $this->getAttributeValue($entry, $this->displayNameAttribute)[0] ?? null)
->setEmail($this->getAttributeValue($entry, $this->emailAttribute)[0] ?? null)
->setUsername($this->getAttributeValue($entry, $this->usernameAttribute) ?? null);
$this->userRepository->getEntityManager()->persist($dbUser);
$this->userRepository->getEntityManager()->flush();
return $dbUser;
}
/** @return User */
private function getDbUser(string $identifier, Entry $entry): ?UserInterface
{
if (in_array($this->uidKey, ['mail', 'email'])) {