Add invite-only registration mode

This commit is contained in:
Constantin Graf
2026-08-31 13:14:09 +02:00
parent 303de4930d
commit 3161bbef4a
12 changed files with 82 additions and 17 deletions

View File

@@ -63,11 +63,18 @@ class CreateNewUser implements CreatesNewUsers
],
])->validate();
if ($registrationMode === RegistrationMode::InviteOnly
&& ! app(InvitationService::class)->hasInvitationForEmail((string) $validated['email'])) {
throw ValidationException::withMessages([
'email' => [__('Registration is only available to invited users.')],
]);
if ($registrationMode === RegistrationMode::InviteOnly) {
$invitationService = app(InvitationService::class);
$email = (string) $validated['email'];
if (! $invitationService->hasAcceptedInvitationForEmail($email)) {
$message = $invitationService->hasPendingInvitationForEmail($email)
? __('Please accept the organization invitation sent to your email address before registering.')
: __('Registration is only available to invited users.');
throw ValidationException::withMessages([
'email' => [$message],
]);
}
}
$timezone = null;