fix error handler, skip send

This commit is contained in:
Max Peintner
2024-12-24 09:50:40 +01:00
parent 53fc22e048
commit 807f01f5b5
4 changed files with 12 additions and 0 deletions

View File

@@ -47,6 +47,9 @@ export default async function Page(props: { searchParams: Promise<any> }) {
await resendVerification({ await resendVerification({
userId: sessionFactors?.factors?.user?.id, userId: sessionFactors?.factors?.user?.id,
isInvite: invite === "true", isInvite: invite === "true",
}).catch((error) => {
console.error("Could not resend verification email", error);
throw Error("Could not request email");
}); });
} }
} else if ("userId" in searchParams && userId) { } else if ("userId" in searchParams && userId) {
@@ -54,6 +57,9 @@ export default async function Page(props: { searchParams: Promise<any> }) {
await resendVerification({ await resendVerification({
userId, userId,
isInvite: invite === "true", isInvite: invite === "true",
}).catch((error) => {
console.error("Could not resend verification email", error);
throw Error("Could not request email");
}); });
} }

View File

@@ -92,6 +92,7 @@ export async function registerUser(command: RegisterUserCommand) {
humanUser, humanUser,
session.factors.user.organizationId, session.factors.user.organizationId,
command.authRequestId, command.authRequestId,
//true, // skip send as a mail was send during registration
); );
if (emailVerificationCheck?.redirect) { if (emailVerificationCheck?.redirect) {

View File

@@ -62,6 +62,7 @@ export function checkEmailVerification(
humanUser?: HumanUser, humanUser?: HumanUser,
organization?: string, organization?: string,
authRequestId?: string, authRequestId?: string,
skipSend?: boolean,
) { ) {
if ( if (
!humanUser?.email?.isVerified && !humanUser?.email?.isVerified &&
@@ -82,6 +83,10 @@ export function checkEmailVerification(
); );
} }
if (skipSend) {
params.append("skipsend", "true");
}
return { redirect: `/verify?` + params }; return { redirect: `/verify?` + params };
} }
} }