added footer links, added email alias check

This commit is contained in:
PxlLoewe
2025-06-06 11:54:03 -07:00
parent 587884dfd9
commit b1262c4278
11 changed files with 141 additions and 97 deletions

View File

@@ -51,29 +51,30 @@ export const deletePilotHistory = async (id: number) => {
});
};
export const CheckEmailCode = async (userId: string, code: string) => {
const user = await prisma.user.findUnique({
export const CheckEmailCode = async (code: string) => {
const users = await prisma.user.findMany({
where: {
id: userId,
emailVerificationToken: code,
},
select: {
id: true,
emailVerificationToken: true,
emailVerificationExpiresAt: true,
},
});
if (!user) {
return { error: "Nutzer nicht gefunden" };
}
if (user.emailVerificationToken !== code || !user.emailVerificationExpiresAt) {
return { error: "Falscher Code" };
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: userId,
id: user.id,
},
data: {
emailVerified: true,