fix: preserve invitations for admins with a family
This commit is contained in:
@@ -15,7 +15,7 @@ export async function queueFamilyInvitation(
|
||||
invitedById: string,
|
||||
) {
|
||||
const user = await tx.user.findUniqueOrThrow({ where: { id: userId } });
|
||||
if (!user.kitaId || !user.familyId || user.role !== "ELTERN" || user.emailVerifiedAt || user.passwordHash || user.disabledAt)
|
||||
if (!user.kitaId || !user.familyId || user.emailVerifiedAt || user.passwordHash || user.disabledAt)
|
||||
throw new Error("Dieses Konto benötigt keine Familieneinladung.");
|
||||
const existing = await tx.invitation.findFirst({
|
||||
where: {
|
||||
@@ -99,7 +99,6 @@ export async function deliverFamilyInvitations(
|
||||
user.emailVerifiedAt ||
|
||||
user.disabledAt ||
|
||||
user.passwordHash !== "" ||
|
||||
user.role !== "ELTERN" ||
|
||||
!token ||
|
||||
token.identifier !== user.id ||
|
||||
token.expires <= now
|
||||
@@ -170,7 +169,7 @@ export async function resendFamilyInvitation(
|
||||
where: { id: userId, kitaId, familyId: { not: null } },
|
||||
});
|
||||
if (!user) return { error: "Elternkonto wurde nicht gefunden." };
|
||||
if (user.emailVerifiedAt || user.passwordHash || user.disabledAt || user.role !== "ELTERN")
|
||||
if (user.emailVerifiedAt || user.passwordHash || user.disabledAt)
|
||||
return { error: "Keine offene Einladung gefunden." };
|
||||
if (expectedEmail && user.email !== expectedEmail)
|
||||
return { error: "Die Einladung hat sich geändert. Bitte lade die Seite neu." };
|
||||
|
||||
Reference in New Issue
Block a user