fix invitations not being respected during signup when email case differs

This commit is contained in:
Gregor Vostrak
2026-07-23 20:01:32 +02:00
parent 619c602571
commit f3c6a0b8ae
2 changed files with 39 additions and 1 deletions

View File

@@ -23,6 +23,10 @@ class InvitationService
*/
public function inviteUser(Organization $organization, string $email, Role $role, User $inviter): OrganizationInvitation
{
// Normalize the email so it matches how user emails are stored (see UserService::createUser),
// otherwise a mixed-case invite silently fails to link on registration.
$email = strtolower($email);
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
throw new UserIsAlreadyMemberOfOrganizationApiException;
}
@@ -55,7 +59,7 @@ class InvitationService
$organizations = new Collection;
$invitations = OrganizationInvitation::query()
->where('email', $user->email)
->whereRaw('lower(email) = ?', [strtolower($user->email)])
->whereNotNull('accepted_at')
->get();