mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 11:27:33 +00:00
change send approach
This commit is contained in:
@@ -90,7 +90,7 @@ describe("verify email", () => {
|
||||
});
|
||||
// TODO: Avoid uncaught exception in application
|
||||
cy.once("uncaught:exception", () => false);
|
||||
cy.visit("/verify?userId=221394658884845598&code=abc");
|
||||
cy.visit("/verify?userId=221394658884845598&code=abc&send=true");
|
||||
cy.contains("Could not verify email", { timeout: 10_000 });
|
||||
});
|
||||
});
|
||||
|
@@ -23,7 +23,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
||||
const t = await getTranslations({ locale, namespace: "verify" });
|
||||
const tError = await getTranslations({ locale, namespace: "error" });
|
||||
|
||||
const { userId, loginName, code, organization, requestId, invite } =
|
||||
const { userId, loginName, code, organization, requestId, invite, send } =
|
||||
searchParams;
|
||||
|
||||
const _headers = await headers();
|
||||
@@ -44,7 +44,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
||||
let human: HumanUser | undefined;
|
||||
let id: string | undefined;
|
||||
|
||||
const doSend = invite !== "true";
|
||||
const doSend = send === "true";
|
||||
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
||||
|
||||
@@ -62,7 +62,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
||||
serviceUrl,
|
||||
userId: sessionFactors?.factors?.user?.id,
|
||||
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}}` +
|
||||
(requestId ? `&requestId=${requestId}` : ""),
|
||||
}).catch((error) => {
|
||||
console.error("Could not resend verification email", error);
|
||||
@@ -75,7 +75,7 @@ export default async function Page(props: { searchParams: Promise<any> }) {
|
||||
serviceUrl,
|
||||
userId,
|
||||
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}}` +
|
||||
(requestId ? `&requestId=${requestId}` : ""),
|
||||
}).catch((error) => {
|
||||
console.error("Could not resend verification email", error);
|
||||
|
@@ -1,12 +1,12 @@
|
||||
"use server";
|
||||
|
||||
import {
|
||||
createInviteCode,
|
||||
getLoginSettings,
|
||||
getSession,
|
||||
getUserByID,
|
||||
listAuthenticationMethodTypes,
|
||||
resendEmailCode,
|
||||
resendInviteCode,
|
||||
verifyEmail,
|
||||
verifyInviteCode,
|
||||
verifyTOTPRegistration,
|
||||
@@ -274,14 +274,24 @@ export async function resendVerification(command: resendVerifyEmailCommand) {
|
||||
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
||||
|
||||
const doSend = true;
|
||||
// create a new invite whenever the resend is called
|
||||
return command.isInvite
|
||||
? resendInviteCode({ serviceUrl, userId: command.userId })
|
||||
? createInviteCode({
|
||||
serviceUrl,
|
||||
userId: command.userId,
|
||||
urlTemplate:
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}&invite=true` +
|
||||
(command.requestId ? `&requestId=${command.requestId}` : "") +
|
||||
(doSend ? `&send=${doSend}` : ""),
|
||||
}) //resendInviteCode({ serviceUrl, userId: command.userId })
|
||||
: resendEmailCode({
|
||||
userId: command.userId,
|
||||
serviceUrl,
|
||||
urlTemplate:
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/password/set?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
|
||||
(command.requestId ? `&requestId=${command.requestId}` : ""),
|
||||
`${host.includes("localhost") ? "http://" : "https://"}${host}${basePath}/verify?code={{.Code}}&userId={{.UserID}}&organization={{.OrgID}}` +
|
||||
(command.requestId ? `&requestId=${command.requestId}` : "") +
|
||||
(doSend ? `&send=${doSend}` : ""),
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ export function checkEmailVerified(
|
||||
const paramsVerify = new URLSearchParams({
|
||||
loginName: session.factors?.user?.loginName as string,
|
||||
userId: session.factors?.user?.id as string, // verify needs user id
|
||||
invite: "true", // TODO: check - set this to true as we dont expect old email verification method here
|
||||
send: "true", // set this to true to request a new code immediately
|
||||
});
|
||||
|
||||
if (organization || session.factors?.user?.organizationId) {
|
||||
@@ -87,6 +87,7 @@ export function checkEmailVerification(
|
||||
) {
|
||||
const params = new URLSearchParams({
|
||||
loginName: session.factors?.user?.loginName as string,
|
||||
send: "true", // set this to true as we dont expect old email codes to be valid anymore
|
||||
});
|
||||
|
||||
if (requestId) {
|
||||
|
Reference in New Issue
Block a user