diff --git a/apps/login/cypress/integration/verify.cy.ts b/apps/login/cypress/integration/verify.cy.ts index a26d8b51e2b..1bbe265c028 100644 --- a/apps/login/cypress/integration/verify.cy.ts +++ b/apps/login/cypress/integration/verify.cy.ts @@ -1,11 +1,48 @@ import { stub } from "../support/mock"; describe("/verify", () => { - it("redirects after successful email verification", () => { + it("if no MFA required, redirects to loginname after successful email verification", () => { stub("zitadel.user.v2.UserService", "VerifyEmail"); cy.visit("/verify?userId=123&code=abc&submit=true"); cy.location("pathname", { timeout: 10_000 }).should("eq", "/loginname"); }); + it("if MFA is required, redirects to mfa/set after successful email verification", () => { + stub("zitadel.settings.v2.SettingsService", "GetLoginSettings", { + data: { + settings: { + forceMfa: true, + }, + }, + }); + stub("zitadel.user.v2.UserService", "VerifyEmail"); + // 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: "john@zitadel.com", + // }, + // otpEmail: { // set a factor + // verifiedAt: timestampFromDate( + // new Date("2024-04-04T09:40:55.577Z"), + // ), + // }, + // password: undefined, + // webAuthN: undefined, + // intent: undefined, + // }, + // metadata: {}, + // }, + // }, + // }); + cy.visit("/verify?userId=123&code=abc&submit=true"); + cy.location("pathname", { timeout: 10_000 }).should("eq", "/mfa/set"); + }); it("shows an error if validation failed", () => { stub("zitadel.user.v2.UserService", "VerifyEmail", { code: 3, diff --git a/packages/zitadel-client/src/index.ts b/packages/zitadel-client/src/index.ts index 5ff017ae2fb..2e262dd013f 100644 --- a/packages/zitadel-client/src/index.ts +++ b/packages/zitadel-client/src/index.ts @@ -3,5 +3,5 @@ export { NewAuthorizationBearerInterceptor } from "./interceptors"; // TODO: Move this to `./protobuf.ts` and export it from there export { create, fromJson, toJson } from "@bufbuild/protobuf"; -export { TimestampSchema, timestampDate } from "@bufbuild/protobuf/wkt"; +export { TimestampSchema, timestampDate, timestampFromDate } from "@bufbuild/protobuf/wkt"; export type { Timestamp } from "@bufbuild/protobuf/wkt";