adasdas
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 23:19:24 +02:00
parent 033fdfd598
commit 2c3c84e66f
8 changed files with 164 additions and 8 deletions

View File

@@ -38,28 +38,62 @@ final class AccountGate
];
}
$user = $this->ldap->getUserByUsername($username, ['uid', 'shadowExpire']);
$user = $this->ldap->getUserByUsername($username, ['uid', 'shadowExpire', 'memberOf']);
if (!is_array($user)) {
return [
'allowed' => false,
'state' => 'blocked',
'message' => 'Dieses Konto ist nicht freigeschaltet.',
];
}
$shadowExpire = (string) ($user['shadowexpire'] ?? $user['shadowExpire'] ?? '');
$activeShadowExpire = (string) ($this->config['ldap']['active_shadow_expire'] ?? -1);
$pendingGroupDn = strtolower(trim((string) ($this->config['ldap']['pending_group_dn'] ?? '')));
$memberOf = $this->normalizeMemberOf($user['memberof'] ?? $user['memberOf'] ?? []);
$isPending = $pendingGroupDn !== '' && in_array($pendingGroupDn, $memberOf, true);
if ($shadowExpire !== $activeShadowExpire) {
if ($isPending && $shadowExpire !== $activeShadowExpire) {
return [
'allowed' => false,
'state' => 'pending',
'message' => 'Dieses Konto ist noch nicht freigeschaltet.',
];
}
if ($shadowExpire !== '' && $shadowExpire !== $activeShadowExpire) {
return [
'allowed' => false,
'state' => 'blocked',
'message' => 'Dieses Konto ist derzeit deaktiviert.',
];
}
return [
'allowed' => true,
'state' => 'active',
'message' => 'Konto ist aktiv.',
];
}
/**
* @param mixed $value
* @return array<int, string>
*/
private function normalizeMemberOf(mixed $value): array
{
if (is_string($value)) {
$value = [$value];
}
if (!is_array($value)) {
return [];
}
return array_values(array_filter(array_map(
static fn (mixed $item): string => strtolower(trim((string) $item)),
$value
)));
}
}

View File

@@ -51,6 +51,14 @@ final class RegistrationService
return $this->store->find($id);
}
/**
* @return array<string, mixed>|null
*/
public function findLatestByUsername(string $username): ?array
{
return $this->store->findLatestByUsername($username);
}
/**
* @param array<string, string> $input
* @return array{success: bool, errors?: array<int, string>, request?: array<string, mixed>}

View File

@@ -42,6 +42,37 @@ final class RegistrationStore
return null;
}
/**
* @return array<string, mixed>|null
*/
public function findLatestByUsername(string $username): ?array
{
$username = strtolower(trim($username));
if ($username === '') {
return null;
}
$matches = array_values(array_filter(
$this->read(),
static fn (array $item): bool => strtolower((string) ($item['username'] ?? '')) === $username
));
if ($matches === []) {
return null;
}
usort(
$matches,
static fn (array $left, array $right): int => strcmp(
(string) ($right['created_at'] ?? ''),
(string) ($left['created_at'] ?? '')
)
);
return $matches[0];
}
/**
* @return array<string, mixed>|null
*/