From 0482424a1c70f23b23d7b4d67e8eb8a281c4741f Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Tue, 30 Apr 2024 21:33:27 -0700 Subject: [PATCH] Make merge user step automatic after email verification --- .../saml-config/saml-config-service.ts | 25 ++- backend/src/server/routes/index.ts | 6 +- backend/src/server/routes/v2/user-router.ts | 65 +------- backend/src/services/user/user-service.ts | 122 ++++++-------- frontend/src/hooks/api/users/index.tsx | 3 - frontend/src/hooks/api/users/mutation.tsx | 49 +----- frontend/src/hooks/api/users/queries.tsx | 20 +-- frontend/src/views/Signup/SignupSSO.tsx | 46 +++-- .../EmailConfirmationStep.tsx | 50 ++++-- .../MergeUsersStep/MergeUsersStep.tsx | 157 ------------------ .../components/MergeUsersStep/index.tsx | 1 - .../UserInfoSSOStep/UserInfoSSOStep.tsx | 12 +- .../src/views/Signup/components/index.tsx | 1 - 13 files changed, 159 insertions(+), 398 deletions(-) delete mode 100644 frontend/src/views/Signup/components/MergeUsersStep/MergeUsersStep.tsx delete mode 100644 frontend/src/views/Signup/components/MergeUsersStep/index.tsx diff --git a/backend/src/ee/services/saml-config/saml-config-service.ts b/backend/src/ee/services/saml-config/saml-config-service.ts index 9719b434b..42e77e431 100644 --- a/backend/src/ee/services/saml-config/saml-config-service.ts +++ b/backend/src/ee/services/saml-config/saml-config-service.ts @@ -21,9 +21,12 @@ import { } from "@app/lib/crypto/encryption"; import { BadRequestError } from "@app/lib/errors"; import { AuthTokenType } from "@app/services/auth/auth-type"; +import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-service"; +import { TokenType } from "@app/services/auth-token/auth-token-types"; import { TOrgBotDALFactory } from "@app/services/org/org-bot-dal"; import { TOrgDALFactory } from "@app/services/org/org-dal"; import { TOrgMembershipDALFactory } from "@app/services/org-membership/org-membership-dal"; +import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service"; import { getServerCfg } from "@app/services/super-admin/super-admin-service"; import { TUserDALFactory } from "@app/services/user/user-dal"; import { normalizeUsername } from "@app/services/user/user-fns"; @@ -48,6 +51,8 @@ type TSamlConfigServiceFactoryDep = { orgBotDAL: Pick; permissionService: Pick; licenseService: Pick; + tokenService: Pick; + smtpService: Pick; }; export type TSamlConfigServiceFactory = ReturnType; @@ -60,7 +65,9 @@ export const samlConfigServiceFactory = ({ userDAL, userAliasDAL, permissionService, - licenseService + licenseService, + tokenService, + smtpService }: TSamlConfigServiceFactoryDep) => { const createSamlCfg = async ({ cert, @@ -439,6 +446,22 @@ export const samlConfigServiceFactory = ({ await samlConfigDAL.update({ orgId }, { lastUsed: new Date() }); + if (user.email && !user.isEmailVerified) { + const token = await tokenService.createTokenForUser({ + type: TokenType.TOKEN_EMAIL_VERIFICATION, + userId: user.id + }); + + await smtpService.sendMail({ + template: SmtpTemplates.EmailVerification, + subjectLine: "Infisical confirmation code", + recipients: [user.email], + substitutions: { + code: token + } + }); + } + return { isUserCompleted, providerAuthToken }; }; diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts index 31a777716..c75346d1e 100644 --- a/backend/src/server/routes/index.ts +++ b/backend/src/server/routes/index.ts @@ -255,6 +255,7 @@ export const registerRoutes = async ( permissionService, secretApprovalPolicyDAL }); + const tokenService = tokenServiceFactory({ tokenDAL: authTokenDAL, userDAL }); const samlService = samlConfigServiceFactory({ permissionService, orgBotDAL, @@ -263,7 +264,9 @@ export const registerRoutes = async ( userDAL, userAliasDAL, samlConfigDAL, - licenseService + licenseService, + tokenService, + smtpService }); const groupService = groupServiceFactory({ userDAL, @@ -333,7 +336,6 @@ export const registerRoutes = async ( queueService }); - const tokenService = tokenServiceFactory({ tokenDAL: authTokenDAL, userDAL }); const userService = userServiceFactory({ userDAL, userAliasDAL, diff --git a/backend/src/server/routes/v2/user-router.ts b/backend/src/server/routes/v2/user-router.ts index 5760fb593..1f15008c7 100644 --- a/backend/src/server/routes/v2/user-router.ts +++ b/backend/src/server/routes/v2/user-router.ts @@ -2,7 +2,6 @@ import { z } from "zod"; import { AuthTokenSessionsSchema, OrganizationsSchema, UserEncryptionKeysSchema, UsersSchema } from "@app/db/schemas"; import { ApiKeysSchema } from "@app/db/schemas/api-keys"; -import { getConfig } from "@app/lib/config/env"; import { authRateLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { AuthMethod, AuthMode } from "@app/services/auth/auth-type"; @@ -15,13 +14,15 @@ export const registerUserRouter = async (server: FastifyZodProvider) => { rateLimit: authRateLimit }, schema: { + body: z.object({ + username: z.string().trim() + }), response: { 200: z.object({}) } }, - preHandler: verifyAuth([AuthMode.JWT]), handler: async (req) => { - await server.services.user.sendEmailVerificationCode(req.permission.id); + await server.services.user.sendEmailVerificationCode(req.body.username); return {}; } }); @@ -34,73 +35,19 @@ export const registerUserRouter = async (server: FastifyZodProvider) => { }, schema: { body: z.object({ + username: z.string().trim(), code: z.string().trim() }), response: { 200: z.object({}) } }, - preHandler: verifyAuth([AuthMode.JWT]), handler: async (req) => { - await server.services.user.verifyEmailVerificationCode(req.permission.id, req.body.code); + await server.services.user.verifyEmailVerificationCode(req.body.username, req.body.code); return {}; } }); - server.route({ - method: "GET", - url: "/me/users/same-email", - config: { - rateLimit: readLimit - }, - schema: { - response: { - 200: z.object({ - users: UsersSchema.array() - }) - } - }, - preHandler: verifyAuth([AuthMode.JWT]), - handler: async (req) => { - const users = await server.services.user.listUsersWithSameEmail(req.permission.id); - return { - users - }; - } - }); - - server.route({ - method: "POST", - url: "/me/users/merge-user", - config: { - rateLimit: writeLimit - }, - schema: { - body: z.object({ - username: z.string().trim() - }), - response: { - 200: z.object({ - user: UsersSchema - }) - } - }, - preHandler: verifyAuth([AuthMode.JWT]), - handler: async (req, res) => { - const appCfg = getConfig(); - const user = await server.services.user.mergeUsers(req.permission.id, req.body.username); - void res.cookie("jid", "", { - httpOnly: true, - path: "/", - sameSite: "strict", - secure: appCfg.HTTPS_ENABLED - }); - return { - user - }; - } - }); - server.route({ method: "PATCH", url: "/me/mfa", diff --git a/backend/src/services/user/user-service.ts b/backend/src/services/user/user-service.ts index 5fc22ba38..6d6bf274a 100644 --- a/backend/src/services/user/user-service.ts +++ b/backend/src/services/user/user-service.ts @@ -16,6 +16,7 @@ type TUserServiceFactoryDep = { | "findById" | "transaction" | "updateById" + | "update" | "deleteById" | "findOneUserAction" | "createUserAction" @@ -36,8 +37,8 @@ export const userServiceFactory = ({ tokenService, smtpService }: TUserServiceFactoryDep) => { - const sendEmailVerificationCode = async (userId: string) => { - const user = await userDAL.findById(userId); + const sendEmailVerificationCode = async (username: string) => { + const user = await userDAL.findOne({ username }); if (!user) throw new BadRequestError({ name: "Failed to find user" }); if (!user.email) throw new BadRequestError({ name: "Failed to send email verification code due to no email on user" }); @@ -59,8 +60,8 @@ export const userServiceFactory = ({ }); }; - const verifyEmailVerificationCode = async (userId: string, code: string) => { - const user = await userDAL.findById(userId); + const verifyEmailVerificationCode = async (username: string, code: string) => { + const user = await userDAL.findOne({ username }); if (!user) throw new BadRequestError({ name: "Failed to find user" }); if (user.isEmailVerified) throw new BadRequestError({ name: "Failed to verify email verification code due to email already verified" }); @@ -71,86 +72,65 @@ export const userServiceFactory = ({ code }); - await userDAL.updateById(userId, { isEmailVerified: true }); - }; - - // lists users with same verified email only - const listUsersWithSameEmail = async (userId: string) => { - const user = await userDAL.findById(userId); - if (!user) throw new BadRequestError({ name: "Failed to find user" }); - if (!user.email) - throw new BadRequestError({ name: "Failed to list users with same email due to no email on user" }); - if (!user.isEmailVerified) - throw new BadRequestError({ name: "Failed to list users with same email due to email not verified" }); - - const users = await userDAL.find({ - email: user.email, - isEmailVerified: true - }); - - return users; - }; - - /** - * Merges two users with the same email. Specifically: - * - Deletes the current user with id [userId] and transfers any resources to the user with username [username] - * @param userId - * @param username - */ - const mergeUsers = async (userId: string, username: string) => { - const targetUser = await userDAL.transaction(async (tx) => { - const myUser = await userDAL.findById(userId, tx); - if (!myUser || !myUser.isEmailVerified) throw new BadRequestError({}); - - const mergeUser = await userDAL.findOne( + await userDAL.transaction(async (tx) => { + await userDAL.updateById( + user.id, { - username + isEmailVerified: true }, tx ); - if (!mergeUser || !mergeUser.isEmailVerified) throw new BadRequestError({}); - if (myUser.email !== mergeUser.email) throw new BadRequestError({}); - - const mergeUserOrgMembershipSet = new Set( - (await orgMembershipDAL.find({ userId: mergeUser.id }, { tx })).map((m) => m.orgId) - ); - const myOrgMemberships = (await orgMembershipDAL.find({ userId: myUser.id }, { tx })).filter( - (m) => !mergeUserOrgMembershipSet.has(m.orgId) - ); - - const userAliases = await userAliasDAL.find( + // check if there are users with the same email. + const users = await userDAL.find( { - userId: myUser.id + email: user.email, + isEmailVerified: true }, { tx } ); - await userDAL.deleteById(myUser.id, tx); - if (myOrgMemberships.length) { - await orgMembershipDAL.insertMany( - myOrgMemberships.map((orgMembership) => ({ - ...orgMembership, - userId: mergeUser.id - })), - tx + if (users.length > 1) { + // merge users + const mergeUser = users.find((u) => u.id !== user.id); + if (!mergeUser) throw new BadRequestError({ name: "Failed to find merge user" }); + + const mergeUserOrgMembershipSet = new Set( + (await orgMembershipDAL.find({ userId: mergeUser.id }, { tx })).map((m) => m.orgId) ); - } - - if (userAliases.length) { - await userAliasDAL.insertMany( - userAliases.map((userAlias) => ({ - ...userAlias, - userId: mergeUser.id - })), - tx + const myOrgMemberships = (await orgMembershipDAL.find({ userId: user.id }, { tx })).filter( + (m) => !mergeUserOrgMembershipSet.has(m.orgId) ); - } - return mergeUser; + const userAliases = await userAliasDAL.find( + { + userId: user.id + }, + { tx } + ); + await userDAL.deleteById(user.id, tx); + + if (myOrgMemberships.length) { + await orgMembershipDAL.insertMany( + myOrgMemberships.map((orgMembership) => ({ + ...orgMembership, + userId: mergeUser.id + })), + tx + ); + } + + if (userAliases.length) { + await userAliasDAL.insertMany( + userAliases.map((userAlias) => ({ + ...userAlias, + userId: mergeUser.id + })), + tx + ); + } + } }); - - return targetUser; }; const toggleUserMfa = async (userId: string, isMfaEnabled: boolean) => { @@ -217,8 +197,6 @@ export const userServiceFactory = ({ return { sendEmailVerificationCode, verifyEmailVerificationCode, - listUsersWithSameEmail, - mergeUsers, toggleUserMfa, updateUserName, updateAuthMethods, diff --git a/frontend/src/hooks/api/users/index.tsx b/frontend/src/hooks/api/users/index.tsx index 72ad7ea6b..a8ad89f4c 100644 --- a/frontend/src/hooks/api/users/index.tsx +++ b/frontend/src/hooks/api/users/index.tsx @@ -1,13 +1,11 @@ export { useAddUserToWsE2EE, useAddUserToWsNonE2EE, - useMergeUsers, useSendEmailVerificationCode, useVerifyEmailVerificationCode } from "./mutation"; export { fetchOrgUsers, - fetchUsersWithMyEmail, useAddUserToOrg, useCreateAPIKey, useDeleteAPIKey, @@ -21,7 +19,6 @@ export { useGetOrgUsers, useGetUser, useGetUserAction, - useListUsersWithMyEmail, useLogoutUser, useRegisterUserAction, useRevokeMySessions, diff --git a/frontend/src/hooks/api/users/mutation.tsx b/frontend/src/hooks/api/users/mutation.tsx index 1f968ec07..20e986aab 100644 --- a/frontend/src/hooks/api/users/mutation.tsx +++ b/frontend/src/hooks/api/users/mutation.tsx @@ -5,11 +5,9 @@ import { encryptAssymmetric } from "@app/components/utilities/cryptography/crypto"; import { apiRequest } from "@app/config/request"; -import { setAuthToken } from "@app/reactQuery"; import { workspaceKeys } from "../workspace/queries"; -import { userKeys } from "./queries"; -import { AddUserToWsDTOE2EE, AddUserToWsDTONonE2EE, User } from "./types"; +import { AddUserToWsDTOE2EE, AddUserToWsDTONonE2EE } from "./types"; export const useAddUserToWsE2EE = () => { const queryClient = useQueryClient(); @@ -64,58 +62,29 @@ export const useAddUserToWsNonE2EE = () => { }); }; -export const sendEmailVerificationCode = async () => { - return apiRequest.post("/api/v2/users/me/emails/code"); +export const sendEmailVerificationCode = async (username: string) => { + return apiRequest.post("/api/v2/users/me/emails/code", { + username + }); }; export const useSendEmailVerificationCode = () => { return useMutation({ - mutationFn: async () => { - await sendEmailVerificationCode(); + mutationFn: async (username: string) => { + await sendEmailVerificationCode(username); return {}; } }); }; export const useVerifyEmailVerificationCode = () => { - const queryClient = useQueryClient(); return useMutation({ - mutationFn: async ({ code }: { code: string }) => { + mutationFn: async ({ username, code }: { username: string; code: string }) => { await apiRequest.post("/api/v2/users/me/emails/verify", { + username, code }); return {}; - }, - onSuccess: () => { - queryClient.invalidateQueries(userKeys.usersWithMyEmail); - } - }); -}; - -export const useMergeUsers = () => { - const queryClient = useQueryClient(); - return useMutation({ - mutationFn: async ({ username }: { username: string }) => { - const { data } = await apiRequest.post<{ user: User }>("/api/v2/users/me/users/merge-user", { - username - }); - return data; - }, - onSuccess: () => { - setAuthToken(""); - // Delete the cookie by not setting a value; Alternatively clear the local storage - localStorage.removeItem("protectedKey"); - localStorage.removeItem("protectedKeyIV"); - localStorage.removeItem("protectedKeyTag"); - localStorage.removeItem("publicKey"); - localStorage.removeItem("encryptedPrivateKey"); - localStorage.removeItem("iv"); - localStorage.removeItem("tag"); - localStorage.removeItem("PRIVATE_KEY"); - localStorage.removeItem("orgData.id"); - localStorage.removeItem("projectData.id"); - - queryClient.clear(); } }); }; diff --git a/frontend/src/hooks/api/users/queries.tsx b/frontend/src/hooks/api/users/queries.tsx index 9bec3f19e..a443c6750 100644 --- a/frontend/src/hooks/api/users/queries.tsx +++ b/frontend/src/hooks/api/users/queries.tsx @@ -26,8 +26,7 @@ export const userKeys = { myAPIKeys: ["api-keys"] as const, myAPIKeysV2: ["api-keys-v2"] as const, mySessions: ["sessions"] as const, - myOrganizationProjects: (orgId: string) => [{ orgId }, "organization-projects"] as const, - usersWithMyEmail: ["users-with-my-email"] as const + myOrganizationProjects: (orgId: string) => [{ orgId }, "organization-projects"] as const }; export const fetchUserDetails = async () => { @@ -352,20 +351,3 @@ export const useGetMyOrganizationProjects = (orgId: string) => { enabled: true }); }; - -export const fetchUsersWithMyEmail = async () => { - const { - data: { users } - } = await apiRequest.get<{ users: User[] }>("/api/v2/users/me/users/same-email"); - return users; -}; - -export const useListUsersWithMyEmail = () => { - return useQuery({ - queryKey: userKeys.usersWithMyEmail, - queryFn: async () => { - return fetchUsersWithMyEmail(); - }, - enabled: true - }); -}; diff --git a/frontend/src/views/Signup/SignupSSO.tsx b/frontend/src/views/Signup/SignupSSO.tsx index cf25b918d..88021ab44 100644 --- a/frontend/src/views/Signup/SignupSSO.tsx +++ b/frontend/src/views/Signup/SignupSSO.tsx @@ -1,12 +1,7 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import jwt_decode from "jwt-decode"; -import { - BackupPDFStep, - EmailConfirmationStep, - MergeUsersStep, - UserInfoSSOStep -} from "./components"; +import { BackupPDFStep, EmailConfirmationStep, UserInfoSSOStep } from "./components"; type Props = { providerAuthToken: string; @@ -27,13 +22,30 @@ export const SignupSSO = ({ providerAuthToken }: Props) => { isEmailVerified } = jwt_decode(providerAuthToken) as any; + useEffect(() => { + if (!isEmailVerified) { + setStep(0); + } else { + setStep(1); + } + }, []); + const renderView = () => { switch (step) { case 0: + return ( + + ); + case 1: return ( { providerAuthToken={providerAuthToken} /> ); - case 1: - return ; + // case 2: + // return ( + // + // ); case 2: - return ( - - ); - case 3: return ( ); diff --git a/frontend/src/views/Signup/components/EmailConfirmationStep/EmailConfirmationStep.tsx b/frontend/src/views/Signup/components/EmailConfirmationStep/EmailConfirmationStep.tsx index f3a36c8dc..c608fb99c 100644 --- a/frontend/src/views/Signup/components/EmailConfirmationStep/EmailConfirmationStep.tsx +++ b/frontend/src/views/Signup/components/EmailConfirmationStep/EmailConfirmationStep.tsx @@ -2,18 +2,19 @@ // if same email exists, then trigger fn to merge automatically import { useState } from "react"; import ReactCodeInput from "react-code-input"; +import { useRouter } from "next/router"; import Error from "@app/components/basic/Error"; import { createNotification } from "@app/components/notifications"; import { Button } from "@app/components/v2"; -import { - fetchUsersWithMyEmail, - useSendEmailVerificationCode, - useVerifyEmailVerificationCode -} from "@app/hooks/api"; +import { useSendEmailVerificationCode, useVerifyEmailVerificationCode } from "@app/hooks/api"; +import { UserAliasType } from "@app/hooks/api/users/types"; type Props = { + authType?: UserAliasType; + username: string; email: string; + organizationSlug: string; setStep: (step: number) => void; }; @@ -55,7 +56,14 @@ const propsPhone = { } } as const; -export const EmailConfirmationStep = ({ email, setStep }: Props) => { +export const EmailConfirmationStep = ({ + authType, + username, + email, + organizationSlug, + setStep +}: Props) => { + const router = useRouter(); const [code, setCode] = useState(""); const [codeError, setCodeError] = useState(false); const [isResendingVerificationEmail] = useState(false); @@ -66,19 +74,29 @@ export const EmailConfirmationStep = ({ email, setStep }: Props) => { const checkCode = async () => { try { - await verifyEmailVerificationCode({ code }); + await verifyEmailVerificationCode({ username, code }); setCodeError(false); - const usersWithSameEmail = await fetchUsersWithMyEmail(); - - if (usersWithSameEmail.length > 1) { - setStep(2); - } - createNotification({ text: "Successfully verified code", type: "success" }); + + switch (authType) { + case UserAliasType.SAML: { + window.open(`/api/v1/sso/redirect/saml2/organizations/${organizationSlug}`); + window.close(); + break; + } + case UserAliasType.LDAP: { + router.push(`/login/ldap?organizationSlug=${organizationSlug}`); + break; + } + default: { + setStep(1); + break; + } + } } catch (err) { createNotification({ text: "Failed to verify code", @@ -91,7 +109,11 @@ export const EmailConfirmationStep = ({ email, setStep }: Props) => { const resendCode = async () => { try { - await sendEmailVerificationCode(); + await sendEmailVerificationCode(username); + createNotification({ + text: "Successfully resent code", + type: "success" + }); } catch (err) { createNotification({ text: "Failed to resend code", diff --git a/frontend/src/views/Signup/components/MergeUsersStep/MergeUsersStep.tsx b/frontend/src/views/Signup/components/MergeUsersStep/MergeUsersStep.tsx deleted file mode 100644 index 42b718c45..000000000 --- a/frontend/src/views/Signup/components/MergeUsersStep/MergeUsersStep.tsx +++ /dev/null @@ -1,157 +0,0 @@ -import { useState } from "react"; -import { useRouter } from "next/router"; -import { faUsers } from "@fortawesome/free-solid-svg-icons"; - -import { createNotification } from "@app/components/notifications"; -import { - Button, - EmptyState, - Modal, - ModalContent, - Table, - TableContainer, - TableSkeleton, - TBody, - Td, - Th, - THead, - Tr -} from "@app/components/v2"; -import { useListUsersWithMyEmail, useMergeUsers } from "@app/hooks/api"; -import { UserAliasType } from "@app/hooks/api/users/types"; - -type Props = { - username: string; - authType?: UserAliasType; - organizationSlug: string; -}; - -export const MergeUsersStep = ({ username, authType, organizationSlug }: Props) => { - const router = useRouter(); - const [isOpen, setIsOpen] = useState(false); - const [targetUsername, setTargetUsername] = useState(""); - const { data: users, isLoading: isLoadingUsers } = useListUsersWithMyEmail(); - const { mutateAsync: mergeUser, isLoading: isLoadingMerge } = useMergeUsers(); - const handleMergeUser = async (mergeWithUsername: string) => { - try { - if (!mergeWithUsername) return; - await mergeUser({ username: mergeWithUsername }); - - createNotification({ - text: "Successfully merged user", - type: "success" - }); - - setIsOpen(false); - - switch (authType) { - case UserAliasType.SAML: { - window.open(`/api/v1/sso/redirect/saml2/organizations/${organizationSlug}`); - window.close(); - break; - } - case UserAliasType.LDAP: { - router.push(`/login/ldap?organizationSlug=${organizationSlug}`); - break; - } - default: { - router.push("/login"); - break; - } - } - - setTargetUsername(""); - } catch (err) { - console.error(err); - createNotification({ - text: "Failed to merge user", - type: "error" - }); - } - }; - - return ( -
-

- We found an account with the same verified email. -

-

- Select the account to merge with it. -

- - - - - - - - - - {isLoadingUsers && } - {!isLoadingUsers && - users - ?.filter((user) => user.username !== username) - ?.map((user) => { - return ( - - - - - - ); - })} - {!isLoadingUsers && !users?.length && ( - - - - )} - -
NameUsername -
{`${user.firstName ?? ""} ${user.lastName ?? ""}`}{user.username} - -
- -
-
- - -

- The merge operation will transfer / consolidate your existing organization membership to - the target user you're merging with. -

-

- If the target user is not yet part of the same organization, then they will be added to - it under your current organization membership. Conversely, if the target user is already - part of the organization, then their existing organization membership will remain. -

-

- Once the merge operation is complete, you'll be prompted to re-login. -

-
- - -
-
-
-
- ); -}; diff --git a/frontend/src/views/Signup/components/MergeUsersStep/index.tsx b/frontend/src/views/Signup/components/MergeUsersStep/index.tsx deleted file mode 100644 index 2cc931b0a..000000000 --- a/frontend/src/views/Signup/components/MergeUsersStep/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { MergeUsersStep } from "./MergeUsersStep"; diff --git a/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx b/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx index 0fadee48b..69168e0af 100644 --- a/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx +++ b/frontend/src/views/Signup/components/UserInfoSSOStep/UserInfoSSOStep.tsx @@ -17,7 +17,6 @@ import SecurityClient from "@app/components/utilities/SecurityClient"; import { Button, Input } from "@app/components/v2"; import { completeAccountSignup, useSelectOrganization } from "@app/hooks/api/auth/queries"; import { fetchOrganizations } from "@app/hooks/api/organization/queries"; -import { sendEmailVerificationCode } from "@app/hooks/api/users/mutation"; import ProjectService from "@app/services/ProjectService"; // eslint-disable-next-line new-cap @@ -26,7 +25,6 @@ const client = new jsrp.client(); type Props = { setStep: (step: number) => void; username: string; - isEmailVerified?: boolean; password: string; setPassword: (value: string) => void; name: string; @@ -60,7 +58,6 @@ type Errors = { */ export const UserInfoSSOStep = ({ username, - isEmailVerified, name, providerOrganizationName, password, @@ -204,14 +201,7 @@ export const UserInfoSSOStep = ({ localStorage.setItem("orgData.id", orgId); localStorage.setItem("projectData.id", project.id); - if (isEmailVerified) { - // move to backup PDF step - setStep(3); - } else { - // move to verify email - await sendEmailVerificationCode(); - setStep(1); - } + setStep(2); } catch (error) { setIsLoading(false); console.error(error); diff --git a/frontend/src/views/Signup/components/index.tsx b/frontend/src/views/Signup/components/index.tsx index 4362a6f4f..7ab3d853c 100644 --- a/frontend/src/views/Signup/components/index.tsx +++ b/frontend/src/views/Signup/components/index.tsx @@ -1,4 +1,3 @@ export { BackupPDFStep } from "./BackupPDFStep"; export { EmailConfirmationStep } from "./EmailConfirmationStep"; -export { MergeUsersStep } from "./MergeUsersStep"; export { UserInfoSSOStep } from "./UserInfoSSOStep";