Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvements: address feedback and update verified login/sign-up flow

Scott Wilson6cb6003de6c5
diff --git a/backend/e2e-test/routes/v3/auth-signup-oauth.spec.ts b/backend/e2e-test/routes/v3/auth-signup-oauth.spec.ts
index bcea5fb409..6a3aa60cd1 100644
--- a/backend/e2e-test/routes/v3/auth-signup-oauth.spec.ts
+++ b/backend/e2e-test/routes/v3/auth-signup-oauth.spec.ts
@@ -6,6 +6,7 @@ import { Knex } from "knex";
import { TableName } from "@app/db/schemas";
import { seedData1 } from "@app/db/seed-data";
import { AuthMethod, AuthTokenType, ProviderAuthResult } from "@app/services/auth/auth-type";
+import { UserAliasType } from "@app/services/user-alias/user-alias-types";
import { TTestSmtpService } from "../../mocks/smtp";
@@ -21,14 +22,20 @@ const findEmailTo = (recipient: string) =>
// Drives the OAuth login the way each passport strategy does, varying only the provider's
// email-verification signal. authMethod defaults to Google; pass GITHUB/GITLAB to assert the
-// per-provider flag is set.
-const oauthLogin = (opts: { email: string; isEmailVerifiedByProvider: boolean; authMethod?: AuthMethod }) =>
+// per-provider flag is set. Pin providerUserId to simulate repeat logins from the same
+// provider account.
+const oauthLogin = (opts: {
+ email: string;
+ isEmailVerifiedByProvider: boolean;
+ authMethod?: AuthMethod;
+ providerUserId?: string;
+}) =>
getServices().login.oauth2Login({
email: opts.email,
firstName: "OAuth",
lastName: "Test",
authMethod: opts.authMethod ?? AuthMethod.GOOGLE,
- providerUserId: `oauth-${crypto.randomUUID()}`,
+ providerUserId: opts.providerUserId ?? `oauth-${crypto.randomUUID()}`,
isEmailVerifiedByProvider: opts.isEmailVerifiedByProvider,
ip: "127.0.0.1",
userAgent: "test-agent"
@@ -42,6 +49,9 @@ const completeAccount = (signupToken: string, code: string) =>
body: { type: "alias", code }
});
+const findUser = (id: string) => getDb()(TableName.Users).where({ id }).first();
+const findAlias = (userId: string) => getDb()(TableName.UserAliases).where({ userId }).first();
+
describe("Auth OAuth Signup V3 (provider-attested email verification)", () => {
const createdUserIds: string[] = [];
@@ -66,24 +76,27 @@ describe("Auth OAuth Signup V3 (provider-attested email verification)", () => {
expect(result.result).toBe(ProviderAuthResult.SIGNUP_REQUIRED);
expect(result.signupToken).toBeDefined();
+ expect(result.didCompleteSignup).toBe(false);
createdUserIds.push(result.user.id);
const decoded = decode(result.signupToken) as Record<string, unknown>;
expect(decoded.authTokenType).toBe(AuthTokenType.SIGNUP_TOKEN);
expect(decoded.isEmailVerified).toBe(false);
+ expect(decoded.aliasId).toBeDefined();
// a verification code email must have been sent
const verificationEmail = findEmailTo(email);
expect(verificationEmail).toBeDefined();
expect((verificationEmail?.substitutions as Record<string, string>)?.code).toBeDefined();
- // and the user is persisted as unverified
- const user = await getDb()(TableName.Users).where({ id: result.user.id }).first();
+ // and the user is persisted as unverified and not accepted
+ const user = await findUser(result.user.id);
expect(user?.isEmailVerified).toBe(false);
+ expect(user?.isAccepted).toBe(false);
expect(user?.isGoogleVerified ?? false).toBe(false);
});
- test("completion rejects a wrong code and accepts the emailed code", async () => {
+ test("completion rejects wrong and empty codes and accepts the emailed code", async () => {
const email = `oauth-code-${crypto.randomUUID()}@localhost.local`;
const result = await oauthLogin({ email, isEmailVerifiedByProvider: false });
createdUserIds.push(result.user.id);
@@ -94,47 +107,74 @@ describe("Auth OAuth Signup V3 (provider-attested email verification)", () => {
const wrong = await completeAccount(result.signupToken, "000000");
expect(wrong.statusCode).toBeGreaterThanOrEqual(400);
+ // an empty code must never bypass verification
+ const empty = await completeAccount(result.signupToken, "");
+ expect(empty.statusCode).toBeGreaterThanOrEqual(400);
+
const ok = await completeAccount(result.signupToken, code);
expect(ok.statusCode).toBe(200);
- const user = await getDb()(TableName.Users).where({ id: result.user.id }).first();
+ const user = await findUser(result.user.id);
expect(user?.isEmailVerified).toBe(true);
expect(user?.isAccepted).toBe(true);
});
+
+ test("repeat login after completion returns a session without a signup signal", async () => {
+ const email = `oauth-repeat-${crypto.randomUUID()}@localhost.local`;
+ const providerUserId = `oauth-${crypto.randomUUID()}`;
+
+ const first = await oauthLogin({ email, isEmailVerifiedByProvider: false, providerUserId });
+ createdUserIds.push(first.user.id);
+ const code = (findEmailTo(email)?.substitutions as Record<string, string>)?.code;
+ expect(code).toBeDefined();
+ const completion = await completeAccount(first.signupToken, code);
+ expect(completion.statusCode).toBe(200);
+
+ const second = await oauthLogin({ email, isEmailVerifiedByProvider: false, providerUserId });
+ expect(second.result).toBe(ProviderAuthResult.SESSION);
+ expect(second.didCompleteSignup).toBe(false);
+ });
});
- describe("provider verified the email -> our verification is skipped", () => {
- test("new user gets a verified token, no verification email, and a verified user record", async () => {
+ describe("provider verified the email -> a session is issued directly, no completion step", () => {
+ test("new user gets a session, a fully accepted account, and no verification email", async () => {
const email = `oauth-verified-${crypto.randomUUID()}@localhost.local`;
const result = await oauthLogin({ email, isEmailVerifiedByProvider: true });
-
- expect(result.result).toBe(ProviderAuthResult.SIGNUP_REQUIRED);
createdUserIds.push(result.user.id);
- const decoded = decode(result.signupToken) as Record<string, unknown>;
- expect(decoded.isEmailVerified).toBe(true);
+ expect(result.result).toBe(ProviderAuthResult.SESSION);
+ expect(typeof result.tokens.access).toBe("string");
+ expect(typeof result.tokens.refresh).toBe("string");
+ expect(result.signupToken).toBeUndefined();
+ expect(result.didCompleteSignup).toBe(true);
+
+ const decodedAccess = decode(result.tokens.access) as Record<string, unknown>;
+ expect(decodedAccess.authTokenType).toBe(AuthTokenType.ACCESS_TOKEN);
// no verification email should have been sent
expect(findEmailTo(email)).toBeUndefined();
- const user = await getDb()(TableName.Users).where({ id: result.user.id }).first();
+ const user = await findUser(result.user.id);
+ expect(user?.isAccepted).toBe(true);
expect(user?.isEmailVerified).toBe(true);
expect(user?.isGoogleVerified).toBe(true);
+
+ const alias = await findAlias(result.user.id);
+ expect(alias?.isEmailVerified).toBe(true);
});
- test("completion succeeds with no code (validation skipped) and accepts the account", async () => {
- const email = `oauth-verified-complete-${crypto.randomUUID()}@localhost.local`;
- const result = await oauthLogin({ email, isEmailVerifiedByProvider: true });
- createdUserIds.push(result.user.id);
+ test("repeat verified login returns a session without a duplicate signup signal", async () => {
+ const email = `oauth-verified-repeat-${crypto.randomUUID()}@localhost.local`;
+ const providerUserId = `oauth-${crypto.randomUUID()}`;
- const res = await completeAccount(result.signupToken, "");
- expect(res.statusCode).toBe(200);
- expect(res.json()).toHaveProperty("token");
+ const first = await oauthLogin({ email, isEmailVerifiedByProvider: true, providerUserId });
+ createdUserIds.push(first.user.id);
+ expect(first.didCompleteSignup).toBe(true);
- const user = await getDb()(TableName.Users).where({ id: result.user.id }).first();
- expect(user?.isAccepted).toBe(true);
- expect(user?.isEmailVerified).toBe(true);
+ const second = await oauthLogin({ email, isEmailVerifiedByProvider: true, providerUserId });
+ expect(second.result).toBe(ProviderAuthResult.SESSION);
+ expect(second.didCompleteSignup).toBe(false);
});
test("GitHub sets the GitHub-specific verified flag", async () => {
@@ -142,9 +182,58 @@ describe("Auth OAuth Signup V3 (provider-attested email verification)", () => {
const result = await oauthLogin({ email, isEmailVerifiedByProvider: true, authMethod: AuthMethod.GITHUB });
createdUserIds.push(result.user.id);
+ expect(result.result).toBe(ProviderAuthResult.SESSION);
expect(findEmailTo(email)).toBeUndefined();
- const user = await getDb()(TableName.Users).where({ id: result.user.id }).first();
+ const user = await findUser(result.user.id);
expect(user?.isGitHubVerified).toBe(true);
});
+
+ test("a verified login completes a previously abandoned unverified signup", async () => {
+ const email = `oauth-resumed-${crypto.randomUUID()}@localhost.local`;
+ const providerUserId = `oauth-${crypto.randomUUID()}`;
+
+ const first = await oauthLogin({ email, isEmailVerifiedByProvider: false, providerUserId });
+ createdUserIds.push(first.user.id);
+ expect(first.result).toBe(ProviderAuthResult.SIGNUP_REQUIRED);
+
+ smtp().clear();
+
+ const second = await oauthLogin({ email, isEmailVerifiedByProvider: true, providerUserId });
+ expect(second.result).toBe(ProviderAuthResult.SESSION);
+ expect(second.didCompleteSignup).toBe(true);
+ expect(findEmailTo(email)).toBeUndefined();
+
+ const user = await findUser(first.user.id);
+ expect(user?.isAccepted).toBe(true);
+ expect(user?.isEmailVerified).toBe(true);
+ const alias = await findAlias(first.user.id);
+ expect(alias?.isEmailVerified).toBe(true);
+ });
+
+ test("an existing accepted user without an alias gets a session and a verified backfilled alias", async () => {
+ const email = `oauth-backfill-${crypto.randomUUID()}@localhost.local`;
+ const [existingUser] = await getDb()(TableName.Users)
+ .insert({
+ username: email,
+ email,
+ isAccepted: true,
+ isEmailVerified: true,
+ isGhost: false,
+ authMethods: [AuthMethod.EMAIL]
+ })
+ .returning("*");
+ createdUserIds.push(existingUser.id);
+
+ const result = await oauthLogin({ email, isEmailVerifiedByProvider: true });
+
+ expect(result.result).toBe(ProviderAuthResult.SESSION);
+ // the account was already accepted, so this login must not look like a signup
+ expect(result.didCompleteSignup).toBe(false);
+ expect(result.user.id).toBe(existingUser.id);
+
+ const alias = await findAlias(existingUser.id);
+ expect(alias?.aliasType).toBe(UserAliasType.GOOGLE);
+ expect(alias?.isEmailVerified).toBe(true);
+ });
});
});
diff --git a/backend/src/server/routes/v1/sso-router.ts b/backend/src/server/routes/v1/sso-router.ts
index 165e88f218..da3a6e4c5e 100644
--- a/backend/src/server/routes/v1/sso-router.ts
+++ b/backend/src/server/routes/v1/sso-router.ts
@@ -34,6 +34,7 @@ import { addAuthOriginDomainCookie } from "@app/server/lib/cookie";
import { AuthMethod, ProviderAuthResult } from "@app/services/auth/auth-type";
import { OrgAuthMethod } from "@app/services/org/org-types";
import { getServerCfg } from "@app/services/super-admin/super-admin-service";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
const passport = new Authenticator({ key: "sso", userProperty: "passportUser" });
@@ -457,6 +458,32 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
const cbPort = passportResult.callbackPort;
if (passportResult.result === ProviderAuthResult.SESSION) {
+ // This login completed the user's signup (provider-verified email), so it never goes
+ // through complete-account; fire the signup telemetry that route would have sent.
+ if (passportResult.didCompleteSignup) {
+ const { user } = passportResult;
+ if (user.email) {
+ void server.services.telemetry.sendLoopsEvent(user.email, user.firstName || "", user.lastName || "");
+ void server.services.telemetry.sendHubSpotSignupEvent(
+ user.email,
+ passportResult.authMethod,
+ user.firstName || "",
+ user.lastName || "",
+ typeof req.cookies?.hubspotutk === "string" ? req.cookies.hubspotutk.slice(0, 512) : undefined
+ );
+ }
+ void server.services.telemetry.sendPostHogEvents({
+ event: PostHogEventTypes.UserSignedUp,
+ distinctId: user.username ?? "",
+ ...(passportResult.orgId ? { organizationId: passportResult.orgId } : {}),
+ properties: {
+ username: user.username,
+ email: user.email ?? "",
+ signupMethod: passportResult.authMethod
+ }
+ });
+ }
+
void res.setCookie("jid", passportResult.tokens.refresh, {
httpOnly: true,
path: "/api",
diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts
index 81493aaf80..940a3d20f1 100644
--- a/backend/src/services/auth/auth-login-service.ts
+++ b/backend/src/services/auth/auth-login-service.ts
@@ -50,6 +50,7 @@ import { LoginMethod } from "../super-admin/super-admin-types";
import { TTotpServiceFactory } from "../totp/totp-service";
import { TUserDALFactory } from "../user/user-dal";
import { TUserAliasDALFactory } from "../user-alias/user-alias-dal";
+import { ensureSsoAccountVerified } from "../user-alias/user-alias-fns";
import { UserAliasType } from "../user-alias/user-alias-types";
import { enforceUserLockStatus, getRequiredMfaMethod, verifyCaptcha } from "./auth-fns";
import {
@@ -862,6 +863,10 @@ export const authLoginServiceFactory = ({
}
}
+ // Captured before any mutation so we can tell whether this login is what completed the
+ // user's signup (used by the caller to fire signup telemetry exactly once per account).
+ const wasUserAcceptedBeforeLogin = Boolean(user?.isAccepted);
+
const serverCfg = await getServerCfg();
if (serverCfg.enabledLoginMethods && user) {
@@ -934,8 +939,9 @@ export const authLoginServiceFactory = ({
username: sanitizedEmail,
email: sanitizedEmail,
// when the provider already verified the email we skip our own verification step
+ // and complete the signup immediately (same as the SAML/OIDC enforced flow)
isEmailVerified: isEmailVerifiedByProvider,
- isAccepted: false,
+ isAccepted: isEmailVerifiedByProvider,
...(authMethod === AuthMethod.GOOGLE && { isGoogleVerified: isEmailVerifiedByProvider }),
...(authMethod === AuthMethod.GITHUB && { isGitHubVerified: isEmailVerifiedByProvider }),
...(authMethod === AuthMethod.GITLAB && { isGitLabVerified: isEmailVerifiedByProvider }),
@@ -1043,7 +1049,7 @@ export const authLoginServiceFactory = ({
tx
);
- await userAliasDAL.updateById(
+ existingAlias = await userAliasDAL.updateById(
existingAlias.id,
{
emails: [sanitizedEmail],
@@ -1087,33 +1093,47 @@ export const authLoginServiceFactory = ({
isAliasVerified = isEmailVerifiedByProvider || Boolean(user.isGitLabVerified);
}
// Self-healing backfill: create alias for existing users found by email fallback
- let aliasId = existingAlias?.id;
if (isNewAlias) {
try {
- const newAlias = await userAliasDAL.create({
+ existingAlias = await userAliasDAL.create({
userId: user.id,
aliasType,
externalId: providerUserId,
emails: [sanitizedEmail],
isEmailVerified: isAliasVerified
});
- aliasId = newAlias.id;
} catch (err) {
- // Swallow duplicate key errors from the unique index (race condition: concurrent login already created the alias)
+ // Duplicate key error from the unique index (race condition: concurrent login already
+ // created the alias), so recover the existing row instead
if (err instanceof DatabaseError && (err.error as { code: string })?.code === "23505") {
logger.warn(`OAuth alias backfill for user ${user.id} skipped: alias already exists`);
+ existingAlias = await userAliasDAL.findOne({ externalId: providerUserId, aliasType });
} else {
throw err;
}
}
}
+ // Provider attested the email (or it was verified previously): promote the user + alias to
+ // verified/accepted so a real session is issued, exactly like the SAML/OIDC enforced flow.
+ // The alias.isEmailVerified term also heals the legacy "alias verified but user never
+ // accepted" state, which would otherwise dead-end (no code is ever issued for it below).
+ if (existingAlias && (isAliasVerified || existingAlias.isEmailVerified)) {
+ ({ user, userAlias: existingAlias } = await ensureSsoAccountVerified({
+ user,
+ userAlias: existingAlias,
+ assertedEmail: sanitizedEmail,
+ userDAL,
+ userAliasDAL
+ }));
+ }
+
// Send verification email for OAuth providers that haven't verified the user's email
- if (!isAliasVerified && user.email && aliasId) {
+ if (user.email && existingAlias && !existingAlias.isEmailVerified) {
const verificationCode = await tokenService.createTokenForUser({
type: TokenType.TOKEN_EMAIL_VERIFICATION,
userId: user.id,
- aliasId
+ aliasId: existingAlias.id
});
await smtpService.sendMail({
@@ -1129,15 +1149,29 @@ export const authLoginServiceFactory = ({
const callbackResult = await processProviderCallback({
user,
authMethod,
- isEmailVerified: isAliasVerified,
- aliasId,
+ // alias-based on purpose: if the promotion above was declined (stale alias) we must fall
+ // back to the signup/verification flow rather than mint a session off a user-level flag
+ isEmailVerified: Boolean(existingAlias?.isEmailVerified),
+ aliasId: existingAlias?.id,
ip,
userAgent,
organizationId: orgId || undefined,
callbackPort
});
- return { ...callbackResult, user: { ...user, hashedPassword: null }, orgId, orgName };
+ // True when this login is the one that completed the account (fresh provider-verified
+ // signup, resumed signup, or an invited user's first verified OAuth login); the caller
+ // uses it to fire signup telemetry that complete-account would otherwise have sent.
+ const didCompleteSignup = !wasUserAcceptedBeforeLogin && Boolean(user.isAccepted);
+
+ return {
+ ...callbackResult,
+ user: { ...user, hashedPassword: null },
+ didCompleteSignup,
+ authMethod,
+ orgId,
+ orgName
+ };
};
/*
diff --git a/backend/src/services/auth/auth-signup-service.ts b/backend/src/services/auth/auth-signup-service.ts
index de16ca81b0..c243ac4b96 100644
--- a/backend/src/services/auth/auth-signup-service.ts
+++ b/backend/src/services/auth/auth-signup-service.ts
@@ -238,21 +238,16 @@ export const authSignupServiceFactory = ({
// Determine rejection before token validation, but don't throw yet
const shouldReject = !user || !decodedToken.aliasId || !userAlias;
- // When the OAuth provider already verified the email, the signed signup token carries
- // isEmailVerified=true and no verification code was ever issued, so skip code validation.
- // The signed token itself is the proof of the provider's verification.
- if (!decodedToken.isEmailVerified) {
- // Always validate the verification code so the bcrypt cost is incurred
- // Use dummy userId when rejecting so the work is still performed
- try {
- await tokenService.validateTokenForUser({
- type: TokenType.TOKEN_EMAIL_VERIFICATION,
- userId: shouldReject ? DUMMY_USER_ID : user.id,
- code: dto.code
- });
- } catch {
- throw new BadRequestError({ message: "Invalid token" });
- }
+ // Always validate the verification code so the bcrypt cost is incurred
+ // Use dummy userId when rejecting so the work is still performed
+ try {
+ await tokenService.validateTokenForUser({
+ type: TokenType.TOKEN_EMAIL_VERIFICATION,
+ userId: shouldReject ? DUMMY_USER_ID : user.id,
+ code: dto.code
+ });
+ } catch {
+ throw new BadRequestError({ message: "Invalid token" });
}
if (shouldReject) {
diff --git a/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx b/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
index 30814b272d..c4282e176f 100644
--- a/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
+++ b/frontend/src/pages/auth/SignUpSsoPage/SignUpSsoPage.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useState } from "react";
import ReactCodeInput from "react-code-input";
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
@@ -79,10 +79,10 @@ export const SignupSsoPage = () => {
SecurityClient.setSignupToken(token);
}, [token]);
- const completeSignup = async (verificationCode: string) => {
+ const handleSubmit = async () => {
const { token: accessToken } = await completeAccountSignup.mutateAsync({
type: "alias",
- code: verificationCode,
+ code,
hubspotUtk: getHubSpotUtk()
});
@@ -109,28 +109,6 @@ export const SignupSsoPage = () => {
}
};
- const handleSubmit = async () => {
- await completeSignup(code);
- };
-
- // When the OAuth provider already verified the email, no code is issued — finish signup automatically.
- const hasAutoCompleted = useRef(false);
- const autoCompleteSignup = () =>
- completeSignup("").catch(() => {
- createNotification({
- text: "Failed to complete sign-up. Please try again.",
- type: "error"
- });
- });
-
- useEffect(() => {
- if (decoded.isEmailVerified && !hasAutoCompleted.current) {
- hasAutoCompleted.current = true;
- autoCompleteSignup();
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [decoded.isEmailVerified]);
-
const handleResendCode = async () => {
try {
await sendEmailVerificationCode(token);
@@ -146,13 +124,6 @@ export const SignupSsoPage = () => {
}
};
- let cardTitle = "We've sent a verification code to";
- if (decoded.isEmailVerified) {
- cardTitle = completeAccountSignup.isError
- ? "Couldn't finish your sign-up"
- : "Finishing your sign-up";
- }
-
return (
<div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4">
<AuthPageBackground />
@@ -174,92 +145,65 @@ export const SignupSsoPage = () => {
<Card className="mx-auto w-full max-w-md items-stretch gap-0 p-6">
<CardHeader className="mb-2 gap-2">
<CardTitle className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-[1.55rem] font-medium text-transparent">
- {cardTitle}
+ We&apos;ve sent a verification code to
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-md my-1 flex justify-center font-medium text-foreground">
{decoded.email}
</p>
- {decoded.isEmailVerified ? (
- <>
- <p className="mt-4 flex justify-center text-center text-sm text-label">
- {completeAccountSignup.isError
- ? "We couldn't finish setting up your account. Please try again."
- : "Your email is already verified. Just a moment while we finish setting up your account…"}
- </p>
- {completeAccountSignup.isError && (
- <div className="mt-4 w-full">
- <Button
- type="button"
- onClick={autoCompleteSignup}
- variant="project"
- size="lg"
- isFullWidth
- isPending={completeAccountSignup.isPending}
- isDisabled={completeAccountSignup.isPending}
- >
- Try again
- </Button>
- </div>
- )}
- </>
- ) : (
- <>
- <div className="mx-auto hidden w-max min-w-[20rem] md:block">
- <ReactCodeInput
- name=""
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setCode}
- {...codeInputStyle}
- className="code-input-v3 mt-6 mb-2"
- />
- </div>
- <div className="mx-auto mt-4 block w-max md:hidden">
- <ReactCodeInput
- name=""
- inputMode="tel"
- type="text"
- fields={6}
- onChange={setCode}
- {...codeInputStylePhone}
- className="code-input-v3 mt-2 mb-2"
- />
- </div>
- {completeAccountSignup.isError && (
- <FieldError>Oops. Your code is wrong. Please try again.</FieldError>
- )}
- <div className="mt-4 w-full">
- <Button
- type="submit"
- onClick={handleSubmit}
- variant="project"
- size="lg"
- isFullWidth
- isPending={completeAccountSignup.isPending}
- isDisabled={completeAccountSignup.isPending}
- >
- Verify
- </Button>
- </div>
- <div className="mt-6 flex flex-col items-center gap-2 text-xs text-label">
- <div className="flex flex-row items-baseline gap-1">
- <button
- disabled={completeAccountSignup.isPending}
- onClick={handleResendCode}
- type="button"
- >
- <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
- Don&apos;t see the code? Resend
- </span>
- </button>
- </div>
- <p className="text-label">Make sure to check your spam inbox.</p>
- </div>
- </>
+ <div className="mx-auto hidden w-max min-w-[20rem] md:block">
+ <ReactCodeInput
+ name=""
+ inputMode="tel"
+ type="text"
+ fields={6}
+ onChange={setCode}
+ {...codeInputStyle}
+ className="code-input-v3 mt-6 mb-2"
+ />
+ </div>
+ <div className="mx-auto mt-4 block w-max md:hidden">
+ <ReactCodeInput
+ name=""
+ inputMode="tel"
+ type="text"
+ fields={6}
+ onChange={setCode}
+ {...codeInputStylePhone}
+ className="code-input-v3 mt-2 mb-2"
+ />
+ </div>
+ {completeAccountSignup.isError && (
+ <FieldError>Oops. Your code is wrong. Please try again.</FieldError>
)}
+ <div className="mt-4 w-full">
+ <Button
+ type="submit"
+ onClick={handleSubmit}
+ variant="project"
+ size="lg"
+ isFullWidth
+ isPending={completeAccountSignup.isPending}
+ isDisabled={completeAccountSignup.isPending}
+ >
+ Verify
+ </Button>
+ </div>
+ <div className="mt-6 flex flex-col items-center gap-2 text-xs text-label">
+ <div className="flex flex-row items-baseline gap-1">
+ <button
+ disabled={completeAccountSignup.isPending}
+ onClick={handleResendCode}
+ type="button"
+ >
+ <span className="cursor-pointer duration-200 hover:text-foreground hover:underline hover:decoration-project/45 hover:underline-offset-2">
+ Don&apos;t see the code? Resend
+ </span>
+ </button>
+ </div>
+ <p className="text-label">Make sure to check your spam inbox.</p>
+ </div>
</CardContent>
</Card>
</div>