Füge E-Mail-Benachrichtigungen für Sperrungen und zeitlich begrenzte Sperrungen hinzu

This commit is contained in:
PxlLoewe
2025-06-28 00:13:55 -07:00
parent 1a1fab3f58
commit 96fcf7e4a5
12 changed files with 445 additions and 53 deletions

View File

@@ -58,42 +58,6 @@ export const deleteUser = async (id: string) => {
});
};
export const checkEmailCode = async (code: string) => {
const users = await prisma.user.findMany({
where: {
emailVerificationToken: code,
},
select: {
id: true,
emailVerificationToken: true,
emailVerificationExpiresAt: true,
},
});
const user = users[0];
if (!user || !user.emailVerificationExpiresAt) {
return { error: "Code ist ungültig" };
}
if (user.emailVerificationExpiresAt < new Date()) {
return { error: "Code ist nicht mehr gültig" };
}
await prisma.user.update({
where: {
id: user.id,
},
data: {
emailVerified: true,
emailVerificationToken: null,
emailVerificationExpiresAt: null,
},
});
return {
message: "Email bestätigt!",
};
};
export const sendVerificationLink = async (userId: string) => {
const code = Math.floor(10000 + Math.random() * 90000).toString();