mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-10 16:15:12 +00:00
# Which Problems Are Solved Enterprise email link scanners (used by organizations for security) pre-fetch URLs in emails to check for malicious content. In Login V2, email verification codes are automatically redeemed when the verification page loads. This causes link scanners to inadvertently consume one-time verification codes before users can click them, resulting in "code already used" errors. # How the Problems Are Solved - Changed the default behaviour so that verification codes are **not** auto-submitted on page load — users must click a Submit button to redeem the code - Added a new environment variable `NEXT_PUBLIC_AUTO_SUBMIT_CODE` that can be set to `true` to re-enable auto-submission for instances where link scanners are not a concern - The env var is named generically so it can be extended to other auto-submit flows (e.g. Email OTP) in the future # Additional Changes None # Additional Context Closes #11406
97 lines
2.8 KiB
TypeScript
97 lines
2.8 KiB
TypeScript
import { stub } from "../support/e2e";
|
|
|
|
describe("verify email", () => {
|
|
beforeEach(() => {
|
|
stub("zitadel.org.v2.OrganizationService", "ListOrganizations", {
|
|
data: {
|
|
details: {
|
|
totalResult: 1,
|
|
},
|
|
result: [{ id: "256088834543534543" }],
|
|
},
|
|
});
|
|
|
|
stub("zitadel.user.v2.UserService", "ListAuthenticationMethodTypes", {
|
|
data: {
|
|
authMethodTypes: [1], // set one method such that we know that the user was not invited
|
|
},
|
|
});
|
|
|
|
stub("zitadel.user.v2.UserService", "SendEmailCode");
|
|
|
|
stub("zitadel.user.v2.UserService", "GetUserByID", {
|
|
data: {
|
|
user: {
|
|
userId: "221394658884845598",
|
|
state: 1,
|
|
username: "[email protected]",
|
|
loginNames: ["[email protected]"],
|
|
preferredLoginName: "[email protected]",
|
|
human: {
|
|
userId: "221394658884845598",
|
|
state: 1,
|
|
username: "[email protected]",
|
|
loginNames: ["[email protected]"],
|
|
preferredLoginName: "[email protected]",
|
|
profile: {
|
|
givenName: "John",
|
|
familyName: "Doe",
|
|
avatarUrl: "https://example.com/avatar.jpg",
|
|
},
|
|
email: {
|
|
email: "[email protected]",
|
|
isVerified: false, // email is not verified yet
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
stub("zitadel.session.v2.SessionService", "CreateSession", {
|
|
data: {
|
|
details: {
|
|
sequence: 859,
|
|
changeDate: new Date("2024-04-04T09:40:55.577Z"),
|
|
resourceOwner: "220516472055706145",
|
|
},
|
|
sessionId: "221394658884845598",
|
|
sessionToken: "SDMc7DlYXPgwRJ-Tb5NlLqynysHjEae3csWsKzoZWLplRji0AYY3HgAkrUEBqtLCvOayLJPMd0ax4Q",
|
|
challenges: undefined,
|
|
},
|
|
});
|
|
|
|
stub("zitadel.session.v2.SessionService", "GetSession", {
|
|
data: {
|
|
session: {
|
|
id: "221394658884845598",
|
|
creationDate: new Date("2024-04-04T09:40:55.577Z"),
|
|
changeDate: new Date("2024-04-04T09:40:55.577Z"),
|
|
sequence: 859,
|
|
factors: {
|
|
user: {
|
|
id: "221394658884845598",
|
|
loginName: "[email protected]",
|
|
},
|
|
password: undefined,
|
|
webAuthN: undefined,
|
|
intent: undefined,
|
|
},
|
|
metadata: {},
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
it("shows an error if email code validation failed", () => {
|
|
stub("zitadel.user.v2.UserService", "VerifyEmail", {
|
|
code: 3,
|
|
error: "error validating code",
|
|
});
|
|
// TODO: Avoid uncaught exception in application
|
|
cy.once("uncaught:exception", () => false);
|
|
cy.visit("/verify?userId=221394658884845598&code=abc");
|
|
cy.get("[data-testid=submit-button]").click();
|
|
cy.contains("Could not verify email");
|
|
});
|
|
});
|