check email sending

This commit is contained in:
Max Peintner
2025-05-21 09:23:44 +02:00
parent 82234da1f4
commit 2dac623c1e
11 changed files with 19 additions and 9 deletions

View File

@@ -90,7 +90,7 @@ describe("verify email", () => {
}); });
// TODO: Avoid uncaught exception in application // TODO: Avoid uncaught exception in application
cy.once("uncaught:exception", () => false); cy.once("uncaught:exception", () => false);
cy.visit("/verify?userId=221394658884845598&code=abc&send=true"); cy.visit("/verify?userId=221394658884845598&code=abc");
cy.contains("Could not verify email", { timeout: 10_000 }); cy.contains("Could not verify email", { timeout: 10_000 });
}); });
}); });

View File

@@ -181,6 +181,7 @@
"description": "Geben Sie den Code ein, der in der Bestätigungs-E-Mail angegeben ist.", "description": "Geben Sie den Code ein, der in der Bestätigungs-E-Mail angegeben ist.",
"noCodeReceived": "Keinen Code erhalten?", "noCodeReceived": "Keinen Code erhalten?",
"resendCode": "Code erneut senden", "resendCode": "Code erneut senden",
"codeSent": "Ein Code wurde gerade an Ihre E-Mail-Adresse gesendet.",
"submit": "Weiter" "submit": "Weiter"
} }
}, },

View File

@@ -181,6 +181,7 @@
"description": "Enter the Code provided in the verification email.", "description": "Enter the Code provided in the verification email.",
"noCodeReceived": "Didn't receive a code?", "noCodeReceived": "Didn't receive a code?",
"resendCode": "Resend code", "resendCode": "Resend code",
"codeSent": "A code has just been sent to your email address.",
"submit": "Continue" "submit": "Continue"
} }
}, },

View File

@@ -181,6 +181,7 @@
"description": "Introduce el código proporcionado en el correo electrónico de verificación.", "description": "Introduce el código proporcionado en el correo electrónico de verificación.",
"noCodeReceived": "¿No recibiste un código?", "noCodeReceived": "¿No recibiste un código?",
"resendCode": "Reenviar código", "resendCode": "Reenviar código",
"codeSent": "Se ha enviado un código a tu dirección de correo electrónico.",
"submit": "Continuar" "submit": "Continuar"
} }
}, },

View File

@@ -181,6 +181,7 @@
"description": "Inserisci il codice fornito nell'email di verifica.", "description": "Inserisci il codice fornito nell'email di verifica.",
"noCodeReceived": "Non hai ricevuto un codice?", "noCodeReceived": "Non hai ricevuto un codice?",
"resendCode": "Invia di nuovo il codice", "resendCode": "Invia di nuovo il codice",
"codeSent": "Un codice è stato appena inviato al tuo indirizzo email.",
"submit": "Continua" "submit": "Continua"
} }
}, },

View File

@@ -181,6 +181,7 @@
"description": "Wprowadź kod z wiadomości weryfikacyjnej.", "description": "Wprowadź kod z wiadomości weryfikacyjnej.",
"noCodeReceived": "Nie otrzymałeś kodu?", "noCodeReceived": "Nie otrzymałeś kodu?",
"resendCode": "Wyślij kod ponownie", "resendCode": "Wyślij kod ponownie",
"codeSent": "Kod został właśnie wysłany na twój adres e-mail.",
"submit": "Kontynuuj" "submit": "Kontynuuj"
} }
}, },

View File

@@ -181,6 +181,7 @@
"description": "Введите код из письма подтверждения.", "description": "Введите код из письма подтверждения.",
"noCodeReceived": "Не получили код?", "noCodeReceived": "Не получили код?",
"resendCode": "Отправить код повторно", "resendCode": "Отправить код повторно",
"codeSent": "Код отправлен на ваш email.",
"submit": "Продолжить" "submit": "Продолжить"
} }
}, },

View File

@@ -181,6 +181,7 @@
"description": "输入验证邮件中的验证码。", "description": "输入验证邮件中的验证码。",
"noCodeReceived": "没有收到验证码?", "noCodeReceived": "没有收到验证码?",
"resendCode": "重发验证码", "resendCode": "重发验证码",
"codeSent": "刚刚发送了一封包含验证码的电子邮件。",
"submit": "继续" "submit": "继续"
} }
}, },

View File

@@ -1,4 +1,4 @@
import { Alert } from "@/components/alert"; import { Alert, AlertType } from "@/components/alert";
import { DynamicTheme } from "@/components/dynamic-theme"; import { DynamicTheme } from "@/components/dynamic-theme";
import { UserAvatar } from "@/components/user-avatar"; import { UserAvatar } from "@/components/user-avatar";
import { VerifyForm } from "@/components/verify-form"; import { VerifyForm } from "@/components/verify-form";
@@ -148,6 +148,12 @@ export default async function Page(props: { searchParams: Promise<any> }) {
</> </>
)} )}
{id && send && (
<div className="py-4 w-full">
<Alert type={AlertType.INFO}>{tError("verify.codesent")}</Alert>
</div>
)}
{sessionFactors ? ( {sessionFactors ? (
<UserAvatar <UserAvatar
loginName={loginName ?? sessionFactors.factors?.user?.loginName} loginName={loginName ?? sessionFactors.factors?.user?.loginName}

View File

@@ -268,13 +268,14 @@ export async function sendLoginname(command: SendLoginnameCommand) {
return inviteCheck; return inviteCheck;
} }
// check if user was verified // check if user was verified recently
const isUserVerified = await checkUserVerification( const isUserVerified = await checkUserVerification(
session.factors.user.id, session.factors.user.id,
); );
if (!isUserVerified) { if (!isUserVerified) {
const params = new URLSearchParams({ const params = new URLSearchParams({
loginName: session.factors?.user?.loginName as string, loginName: session.factors?.user?.loginName as string,
// send: "true", // set this to true to request a new code immediately
}); });
if (command.requestId) { if (command.requestId) {

View File

@@ -274,7 +274,6 @@ export async function resendVerification(command: resendVerifyEmailCommand) {
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? ""; const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
const doSend = true;
// create a new invite whenever the resend is called // create a new invite whenever the resend is called
return command.isInvite return command.isInvite
? createInviteCode({ ? createInviteCode({
@@ -282,22 +281,19 @@ export async function resendVerification(command: resendVerifyEmailCommand) {
userId: command.userId, userId: command.userId,
urlTemplate: urlTemplate:
`${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true` + `${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true` +
(command.requestId ? `&requestId=${command.requestId}` : "") + (command.requestId ? `&requestId=${command.requestId}` : ""),
(doSend ? `&send=${doSend}` : ""),
}) //resendInviteCode({ serviceUrl, userId: command.userId }) }) //resendInviteCode({ serviceUrl, userId: command.userId })
: resendEmailCode({ : resendEmailCode({
userId: command.userId, userId: command.userId,
serviceUrl, serviceUrl,
urlTemplate: urlTemplate:
`${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` + `${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
(command.requestId ? `&requestId=${command.requestId}` : "") + (command.requestId ? `&requestId=${command.requestId}` : ""),
(doSend ? `&send=${doSend}` : ""),
}); });
} }
type sendEmailCommand = { type sendEmailCommand = {
serviceUrl: string; serviceUrl: string;
userId: string; userId: string;
urlTemplate: string; urlTemplate: string;
}; };