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