dadasd
All checks were successful
Deploy / deploy-staging (push) Successful in 24s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-06-15 22:15:01 +02:00
parent f07d8e7110
commit 033fdfd598
10 changed files with 186 additions and 7 deletions

65
src/App/AccountGate.php Normal file
View File

@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace App;
final class AccountGate
{
private LdapProvisioner $ldap;
/**
* @param array<string, mixed> $config
*/
public function __construct(
private readonly array $config,
) {
$this->ldap = new LdapProvisioner($config);
}
/**
* @return array{allowed: bool, message: string}
*/
public function checkUsername(string $username): array
{
$username = strtolower(trim($username));
if ($username === '') {
return [
'allowed' => false,
'message' => 'Für dieses Konto konnte kein Benutzername ermittelt werden.',
];
}
if (!$this->ldap->isEnabled() || !$this->ldap->canUseLdap()) {
return [
'allowed' => false,
'message' => 'Der Kontostatus konnte nicht sicher geprüft werden.',
];
}
$user = $this->ldap->getUserByUsername($username, ['uid', 'shadowExpire']);
if (!is_array($user)) {
return [
'allowed' => false,
'message' => 'Dieses Konto ist nicht freigeschaltet.',
];
}
$shadowExpire = (string) ($user['shadowexpire'] ?? $user['shadowExpire'] ?? '');
$activeShadowExpire = (string) ($this->config['ldap']['active_shadow_expire'] ?? -1);
if ($shadowExpire !== $activeShadowExpire) {
return [
'allowed' => false,
'message' => 'Dieses Konto ist noch nicht freigeschaltet.',
];
}
return [
'allowed' => true,
'message' => 'Konto ist aktiv.',
];
}
}

View File

@@ -64,7 +64,8 @@ final class RegistrationService
$note = trim((string) ($input['note'] ?? ''));
$password = (string) ($input['password'] ?? '');
$passwordConfirm = (string) ($input['password_confirm'] ?? '');
$displayName = trim($givenName . ' ' . $familyName);
$displayName = $givenName;
$fullName = trim($givenName . ' ' . $familyName);
$errors = [];
if (!preg_match('/^[a-z0-9._-]{3,32}$/', $username)) {
@@ -128,7 +129,7 @@ final class RegistrationService
'apple_generateduid' => '',
'display_name' => $displayName,
'cn' => $displayName !== '' ? $displayName : $username,
'gecos' => $displayName,
'gecos' => $fullName !== '' ? $fullName : $displayName,
'admin_note' => '',
'ldap_created_at' => gmdate('c'),
];