Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chg(login): consolidate /login /signup /welcome (#5255)

teo755a4e8b3bfc
diff --git a/apps/web/src/features/auth/EmailForm.tsx b/apps/web/src/features/auth/EmailForm.tsx
index e607a362de..be583f6018 100644
--- a/apps/web/src/features/auth/EmailForm.tsx
+++ b/apps/web/src/features/auth/EmailForm.tsx
@@ -1,15 +1,8 @@
import { SERVER_HOSTS } from '@core/constant/servers';
-import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import { platformFetch } from '@core/util/platformFetch';
-import ArrowLeft from '@phosphor/arrow-left.svg';
-import ArrowRight from '@phosphor/arrow-right.svg';
import { authServiceClient } from '@service-auth/client';
-import { createCallback } from '@solid-primitives/rootless';
-import { action, useSearchParams, useSubmission } from '@solidjs/router';
-import { cn } from '@ui';
-import { createEffect, createSignal, Show, untrack } from 'solid-js';
-import { ErrorMsg, Input, Stage } from './Shared';
+import { action, useSubmission } from '@solidjs/router';
+import { Stage } from './Shared';
// Construct the redirect uri to use for passwordless login.
// This will send us back to the application after clicking the magic link.
@@ -74,11 +67,19 @@ export const sendEmailCode = action(async (formData: FormData) => {
// If the passwordless call returns 202,
// the email needs to login through a dedicated identity provider.
if (response.status === 202) {
- const body = await response.json();
- const idp_id = body.idp_id;
+ const body: unknown = await response.json().catch(() => undefined);
+ if (
+ !body ||
+ typeof body !== 'object' ||
+ !('idp_id' in body) ||
+ typeof body.idp_id !== 'string' ||
+ !body.idp_id
+ ) {
+ throw new Error('Unable to start SSO login for this email.');
+ }
const ssoUrl = new URL(`${SERVER_HOSTS['auth-service']}/login/sso`);
- ssoUrl.searchParams.set('idp_id', idp_id);
- ssoUrl.searchParams.set('login_hint', (email ?? '').toString());
+ ssoUrl.searchParams.set('idp_id', body.idp_id);
+ ssoUrl.searchParams.set('login_hint', email);
if (referral_code) ssoUrl.searchParams.set('referral_code', referral_code);
window.location.href = ssoUrl.toString();
return false; // passwordless login flow is not reached
@@ -119,100 +120,3 @@ export function useResetEmailCode(setStage: (next: Stage) => void) {
setStage(Stage.Email);
};
}
-
-export function EmailForm(props: { setStage: (next: Stage) => void }) {
- const [isPasswordLogin, setIsPasswordLogin] = createSignal(false);
- const submission = useSubmission(sendEmailCode);
- const [searchParams] = useSearchParams();
- const searchParamsEmail = untrack(() => {
- const email = searchParams.email;
- if (typeof email === 'string') return email;
- });
-
- createEffect(() => {
- if (sentEmailCode(submission.result)) {
- props.setStage(Stage.Verify);
- } else if (submission.result === 'isPasswordLogin') {
- setIsPasswordLogin(true);
- } else if (submission.result === 'LoggedIn') {
- props.setStage(Stage.Done);
- }
- });
-
- const handleBack = createCallback(() => {
- submission.clear();
- props.setStage(Stage.None);
- });
-
- return (
- <div class="grid select-none">
- <form action={sendEmailCode} method="post" class="m-0">
- <div
- class={cn(
- 'flex items-center justify-center text-center py-4 px-6 border-y border-edge-muted',
- virtualKeyboardVisible() && 'border-t border-edge-muted'
- )}
- >
- <Input
- value={searchParamsEmail}
- placeholder="Email Address"
- type="email"
- id="email"
- />
- </div>
-
- <Show when={isPasswordLogin()}>
- <div class="grid items-center justify-center py-4 px-6 border-b border-edge-muted">
- <Input
- required={isPasswordLogin()}
- placeholder="Password"
- type="password"
- id="password"
- />
- </div>
- </Show>
-
- <div class="border-b border-edge-muted py-4 px-6 flex flex-none justify-between items-center">
- <button
- class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
- onClick={() => {
- if (isTouchDevice()) return;
- handleBack();
- }}
- // Using onPointerDown so that on touch device able to interact with button before closing virtual keyboard
- onPointerDown={(e) => {
- if (!isTouchDevice()) return;
- e.stopPropagation();
- e.preventDefault();
- handleBack();
- }}
- type="button"
- >
- <ArrowLeft class="size-5" />
- <span>Back</span>
- </button>
-
- <button
- class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
- type="submit"
- disabled={submission.pending}
- onClick={(e) => {
- if (isTouchDevice()) e.preventDefault();
- }}
- // Using onPointerDown so that on touch device able to interact with button before closing virtual keyboard
- onPointerDown={(e) => {
- if (!isTouchDevice()) return;
- e.stopPropagation();
- e.preventDefault();
- e.currentTarget.form?.requestSubmit();
- }}
- >
- <span>Continue</span>
- <ArrowRight class="size-5" />
- </button>
- </div>
- <ErrorMsg msg={submission.error?.message} />
- </form>
- </div>
- );
-}
diff --git a/apps/web/src/features/auth/Login.tsx b/apps/web/src/features/auth/Login.tsx
index 63811a386c..650f8fbe8a 100644
--- a/apps/web/src/features/auth/Login.tsx
+++ b/apps/web/src/features/auth/Login.tsx
@@ -1,46 +1,57 @@
+import { OnboardingFlow } from '@app/features/setup/flow/OnboardingFlow';
+import { NoiseBackground } from '@app/features/setup/flow/shared';
+import { useOnboardingV4Flag } from '@app/features/setup/flow/useOnboardingV4Flag';
import { useAnalytics } from '@app/lib/analytics/analytics-context';
-import { ShowFeatureFlag } from '@app/lib/analytics/posthog';
+import { GOOGLE_GMAIL_IDP } from '@core/auth/email';
import { LoadingBlock } from '@core/component/LoadingBlock';
-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';
-import { ENABLE_NEW_LOGIN_OVERRIDE } from '@core/constant/featureFlags';
import { useEmailLinks } from '@core/email-link';
+import { isMobile } from '@core/mobile/isMobile';
+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import { unsetTokenPromise } from '@core/util/fetchWithToken';
+import { getNativeMobilePlatform } from '@core/util/platform';
+import IconApple from '@icon/macro-apple.svg';
+import IconGoogle from '@icon/macro-google.svg';
import LogoIcon from '@icon/macro-logo.svg';
+import ArrowLeft from '@phosphor/arrow-left.svg';
+import ArrowRight from '@phosphor/arrow-right.svg';
import { useUserInfo } from '@queries/auth';
-import { invalidateAllAfterLogin } from '@queries/auth/user-info';
+import {
+ invalidateAllAfterLogin,
+ useUserInfoQuery,
+} from '@queries/auth/user-info';
import { authServiceClient } from '@service-auth/client';
-import { useNavigate, useSearchParams } from '@solidjs/router';
-import { cn, Surface } from '@ui';
+import {
+ action,
+ useAction,
+ useNavigate,
+ useSearchParams,
+ useSubmission,
+} from '@solidjs/router';
+import { Button } from '@ui';
+import { Stepper } from '@ui/components/Stepper';
import { detect } from 'detect-browser';
import {
createEffect,
createMemo,
createSignal,
- Match,
on,
onCleanup,
onMount,
Show,
- Switch,
+ Suspense,
+ untrack,
} from 'solid-js';
-import { EmailForm } from './EmailForm';
-import { LoginNew } from './LoginNew';
-import { LoginOptions } from './LoginOptions';
+import { match } from 'ts-pattern';
+import {
+ autoLoginCode,
+ sendEmailCode,
+ sentEmailCode,
+ useResetEmailCode,
+} from './EmailForm';
+import { OtpInput } from './OtpInput';
import { Stage } from './Shared';
-import { VerifyForm } from './VerifyForm';
-
-export function Login() {
- return (
- <ShowFeatureFlag
- key="enable-new-login"
- enabledOverride={ENABLE_NEW_LOGIN_OVERRIDE}
- fallback={<LoginOld />}
- >
- <LoginNew />
- </ShowFeatureFlag>
- );
-}
+import { useSsoLogin } from './useSsoLogin';
function PostLoginRedirect() {
const navigate = useNavigate();
@@ -54,10 +65,397 @@ function PostLoginRedirect() {
return <LoadingBlock />;
}
-function LoginOld() {
- const [stage, setStage] = createSignal(Stage.None);
- const userInfo = useUserInfo();
+/**
+ * Where login and onboarding meet: once authenticated, first-time desktop
+ * users continue straight into the onboarding steps IN PLACE — same page,
+ * no redirect — while everyone else proceeds into the app. This keeps
+ * /login a single surface that decides what the user needs next.
+ */
+function PostAuthGate() {
+ const userInfoQuery = useUserInfoQuery();
+ const onboardingV4 = useOnboardingV4Flag();
+
+ const isFirstTimeDesktopUser = () =>
+ !isMobile() &&
+ !isNativeMobilePlatform() &&
+ userInfoQuery.data?.authenticated === true &&
+ userInfoQuery.data.tutorialComplete === false;
+
+ const needsOnboarding = () =>
+ onboardingV4().enabled && isFirstTimeDesktopUser();
+
+ // Don't redirect into the app while the gate is still unknown: a first-time
+ // user would land on home for a beat and then get yanked to /onboarding.
+ const waitingOnFlag = () =>
+ onboardingV4().loading && isFirstTimeDesktopUser();
+
+ return (
+ <Suspense fallback={<LoadingBlock />}>
+ <Show when={userInfoQuery.data} fallback={<LoadingBlock />}>
+ <Show when={!waitingOnFlag()} fallback={<LoadingBlock />}>
+ <Show when={needsOnboarding()} fallback={<PostLoginRedirect />}>
+ <OnboardingFlow />
+ </Show>
+ </Show>
+ </Show>
+ </Suspense>
+ );
+}
+
+function LoginPicker(props: {
+ setStage: (next: Stage) => void;
+ signupMode?: boolean;
+}) {
+ const analytics = useAnalytics();
+ const startSsoLogin = useSsoLogin({ signupMode: props.signupMode });
+ // Apple sign-in is iOS-only: it's required there for App Store review,
+ // and intentionally absent on desktop.
+ const showApple = getNativeMobilePlatform() === 'ios';
+
+ const continueWithEmail = () => {
+ if (props.signupMode) {
+ analytics.track('sign_up_click', { method: 'email' });
+ }
+ props.setStage(Stage.Email);
+ };
+
+ return (
+ <div class="flex flex-col gap-3">
+ <Button
+ variant="cta"
+ autofocus
+ onClick={() => startSsoLogin(GOOGLE_GMAIL_IDP)}
+ >
+ <IconGoogle />
+ Continue with Google
+ </Button>
+
+ <Show when={showApple}>
+ <Button
+ variant="base"
+ class="bg-surface"
+ onClick={() => startSsoLogin('Apple')}
+ >
+ <IconApple />
+ Continue with Apple
+ </Button>
+ </Show>
+
+ <Button variant="base" class="bg-surface" onClick={continueWithEmail}>
+ Continue with email
+ </Button>
+ </div>
+ );
+}
+
+function FormInput(props: {
+ id: string;
+ type?: string;
+ placeholder?: string;
+ required?: boolean;
+ value?: string;
+ autoFocus?: boolean;
+}) {
+ let inputEl: HTMLInputElement | undefined;
+ onMount(() => {
+ if (props.autoFocus === false) return;
+ let cancelled = false;
+ onCleanup(() => {
+ cancelled = true;
+ });
+ // The Stepper's outin Transition resolves this step's JSX (firing onMount)
+ // before attaching it to the document, so the input is still detached
+ // here. Poll until it's connected, then focus.
+ const focusWhenConnected = () => {
+ if (cancelled || !inputEl) return;
+ if (inputEl.isConnected) inputEl.focus({ preventScroll: true });
+ else requestAnimationFrame(focusWhenConnected);
+ };
+ focusWhenConnected();
+ });
+ return (
+ <input
+ ref={(el) => (inputEl = el)}
+ id={props.id}
+ name={props.id}
+ type={props.type ?? 'text'}
+ placeholder={props.placeholder}
+ value={props.value ?? ''}
+ required={props.required ?? true}
+ autocomplete={props.id}
+ class="ln-input w-full px-4 py-3 rounded-lg border border-edge bg-surface text-sm text-ink placeholder:text-ink-placeholder focus:border-accent focus:outline-none transition-colors user-invalid:border-failure"
+ />
+ );
+}
+
+function FormError(props: { msg?: string }) {
+ return (
+ <Show when={props.msg}>
+ <p role="alert" class="text-xs text-failure leading-snug">
+ {props.msg}
+ </p>
+ </Show>
+ );
+}
+
+function EmailFormNew(props: {
+ setStage: (next: Stage) => void;
+ onBack: () => void;
+}) {
+ const [isPasswordLogin, setIsPasswordLogin] = createSignal(false);
+ const submission = useSubmission(sendEmailCode);
+ const send = useAction(sendEmailCode);
const [searchParams] = useSearchParams();
+ const searchParamsEmail = untrack(() => {
+ const email = searchParams.email;
+ if (typeof email === 'string') return email;
+ });
+
+ // Dev builds auto-start the flow for `?email=` links (the seeder prints
+ // them per persona); combined with the local backend returning the code,
+ // opening the link logs straight in.
+ createEffect(() => {
+ if (
+ import.meta.env.DEV &&
+ searchParamsEmail &&
+ !submission.pending &&
+ !submission.result &&
+ !submission.error
+ ) {
+ const formData = new FormData();
+ formData.append('email', searchParamsEmail);
+ send(formData);
+ }
+ });
+
+ createEffect(() => {
+ if (sentEmailCode(submission.result)) {
+ props.setStage(Stage.Verify);
+ } else if (submission.result === 'isPasswordLogin') {
+ setIsPasswordLogin(true);
+ } else if (submission.result === 'LoggedIn') {
+ props.setStage(Stage.Done);
+ }
+ });
+
+ return (
+ <form
+ action={sendEmailCode}
+ method="post"
+ noValidate={false}
+ class="flex flex-col gap-3"
+ >
+ <p class="text-xs text-ink-muted leading-snug">
+ We’ll send a one-time code to verify.
+ </p>
+ <FormInput
+ id="email"
+ type="email"
+ placeholder="[email protected]"
+ value={searchParamsEmail}
+ />
+ <Show when={isPasswordLogin()}>
+ <FormInput
+ id="password"
+ type="password"
+ placeholder="Password"
+ required={isPasswordLogin()}
+ />
+ </Show>
+ <FormError msg={submission.error?.message} />
+ <Button variant="cta" type="submit" disabled={submission.pending}>
+ Continue
+ <ArrowRight class="size-4" />
+ </Button>
+ <Button variant="base" class="bg-surface" onClick={props.onBack}>
+ <ArrowLeft class="size-4" />
+ Back to sign in
+ </Button>
+ </form>
+ );
+}
+
+const verifyCode = action(async (formData: FormData) => {
+ const code = formData.get('one-time-code');
+ if (typeof code !== 'string') throw new Error('Invalid code');
+ const email = formData.get('email');
+ if (typeof email !== 'string') throw new Error('Invalid email');
+
+ const result = await authServiceClient.passwordlessCallback({ code, email });
+ if (result.isErr()) {
+ if (result.error.some((err) => err.code === 'UNAUTHORIZED')) {
+ throw new Error('Invalid code.');
+ }
+ throw new Error('Unable to perform verification.');
+ }
+
+ return true;
+}, 'verify-code-login-new');
+
+const RESEND_TIMER = 45;
+
+function VerifyFormNew(props: {
+ setStage: (next: Stage) => void;
+ onBack: () => void;
+}) {
+ const [code, setCode] = createSignal('');
+ const [resendError, setResendError] = createSignal<string>();
+ const [showResendCode, setShowResendCode] = createSignal(false);
+ const [resendTimer, setResendTimer] = createSignal(RESEND_TIMER);
+ const submission = useSubmission(verifyCode);
+ const emailSubmission = useSubmission(sendEmailCode);
+ const resend = useAction(sendEmailCode);
+ const submit = useAction(verifyCode);
+
+ const email = () => {
+ const value = emailSubmission.input?.[0].get('email');
+ return typeof value === 'string' ? value : undefined;
+ };
+
+ // Local backends return the code with the email step; submit it
+ // automatically so seeded persona logins are one click.
+ createEffect(() => {
+ const code = autoLoginCode(emailSubmission.result);
+ const submittedEmail = email();
+ if (
+ code &&
+ submittedEmail &&
+ !submission.pending &&
+ !submission.result &&
+ !submission.error
+ ) {
+ const formData = new FormData();
+ formData.append('email', submittedEmail);
+ formData.append('one-time-code', code);
+ submit(formData);
+ }
+ });
+
+ createEffect(() => {
+ if (!showResendCode()) {
+ const timer = setTimeout(() => {
+ setResendTimer(0);
+ setShowResendCode(true);
+ }, RESEND_TIMER * 1000);
+ const pTimer = setInterval(
+ () => setResendTimer((t) => (t > 0 ? t - 1 : 0)),
+ 1000
+ );
+ onCleanup(() => {
+ clearTimeout(timer);
+ clearInterval(pTimer);
+ });
+ }
+ });
+
+ const handleResendCode = async () => {
+ const submittedEmail = email();
+ if (!submittedEmail) {
+ setResendError('Email address is unavailable. Go back and try again.');
+ return;
+ }
+ submission.clear();
+ setResendError();
+ setResendTimer(RESEND_TIMER);
+ setShowResendCode(false);
+ const formData = new FormData();
+ formData.append('email', submittedEmail);
+ try {
+ await resend(formData);
+ } catch (e) {
+ console.error(e);
+ setResendTimer(0);
+ setShowResendCode(true);
+ setResendError(
+ e instanceof Error
+ ? e.message
+ : 'Failed to resend code. Please try again.'
+ );
+ }
+ };
+
+ createEffect(() => {
+ if (submission.result) {
+ props.setStage(Stage.Done);
+ const url = new URL(window.location.href);
+ const sp = new URLSearchParams(url.search);
+ const referral = sp.get('referral');
+ if (referral) window.location.href = `/app?referral=${referral}`;
+ }
+ });
+
+ let formEl: HTMLFormElement | undefined;
+
+ return (
+ <form
+ ref={formEl}
+ action={verifyCode}
+ method="post"
+ class="flex flex-col gap-3"
+ >
+ <input type="hidden" name="email" value={email() ?? ''} />
+ <input type="hidden" name="one-time-code" value={code()} />
+ <p class="text-xs text-ink-muted leading-snug">
+ Enter the 6-digit code we sent to{' '}
+ <span class="text-ink font-medium break-all">{email()}</span>.
+ </p>
+ <OtpInput
+ value={code()}
+ disabled={submission.pending}
+ onInput={setCode}
+ onComplete={(value) => {
+ const submittedEmail = email();
+ if (!submittedEmail) return;
+ const formData = new FormData(formEl);
+ formData.set('email', submittedEmail);
+ formData.set('one-time-code', value);
+ submit(formData);
+ }}
+ />
+ <p class="text-center text-xs text-ink-muted" aria-live="polite">
+ Didn't receive a code?{' '}
+ <button
+ type="button"
+ onClick={handleResendCode}
+ disabled={
+ emailSubmission.pending ||
+ submission.pending ||
+ !showResendCode() ||
+ !email()
+ }
+ class="font-medium text-ink transition-colors hover:text-ink-muted disabled:text-ink-extra-muted"
+ >
+ <Show when={resendTimer() > 0} fallback="Resend">
+ Resend ({resendTimer()})
+ </Show>
+ </button>
+ </p>
+ <FormError msg={submission.error?.message ?? resendError()} />
+ {/* The visible pattern-validated input is gone (the code lives in a
+ hidden field, which browsers exempt from constraint validation), so
+ gate submission here instead of round-tripping partial codes. */}
+ <Button
+ variant="cta"
+ type="submit"
+ disabled={submission.pending || code().length !== 6 || !email()}
+ >
+ Verify
+ <ArrowRight class="size-4" />
+ </Button>
+ <Button variant="base" class="bg-surface" onClick={props.onBack}>
+ <ArrowLeft class="size-4" />
+ Change email
+ </Button>
+ </form>
+ );
+}
+
+export function Login(props: { signupMode?: boolean }) {
+ const [searchParams] = useSearchParams();
+ const [stage, setStage] = createSignal(
+ searchParams.email ? Stage.Email : Stage.None
+ );
+ const userInfo = useUserInfo();
const analytics = useAnalytics();
const authenticatedUserId = createMemo(() => {
const user = userInfo();
@@ -65,7 +463,7 @@ function LoginOld() {
});
onMount(() => {
- analytics.pageView('login');
+ analytics.pageView(props.signupMode ? 'signup' : 'login');
});
const identifyUser = () => {
@@ -87,9 +485,6 @@ function LoginOld() {
);
createEffect(() => {
- if (searchParams.email) {
- setStage(Stage.Email);
- }
// token may be an array if the redirect URL contained duplicate token params;
// take the last one as it is the most recently appended by the auth service
const rawToken = searchParams.token;
@@ -97,10 +492,8 @@ function LoginOld() {
? rawToken[rawToken.length - 1]
: rawToken;
if (session_code && typeof session_code === 'string') {
- console.log({ session_code });
unsetTokenPromise();
authServiceClient.sessionLogin({ session_code }).then(async (res) => {
- console.log({ res });
if (res.isOk()) {
await invalidateAllAfterLogin();
await initEmailLink().match(
@@ -150,68 +543,106 @@ function LoginOld() {
setStage(next);
};
+ const stepIndex = () =>
+ match(stage())
+ .with(Stage.None, () => 0)
+ .with(Stage.Email, () => 1)
+ .with(Stage.Verify, () => 2)
+ .with(Stage.Done, () => 2)
+ .exhaustive();
+
+ const emailSubmission = useSubmission(sendEmailCode);
+ const verifySubmission = useSubmission(verifyCode);
+ const resetEmailCode = useResetEmailCode(setStage);
+
+ const onBack = () => {
+ if (stage() === Stage.Verify) {
+ verifySubmission.clear();
+ resetEmailCode();
+ } else if (stage() === Stage.Email) {
+ emailSubmission.clear();
+ setStage(Stage.None);
+ }
+ };
+
return (
- <Show when={!userInfo()?.authenticated} fallback={<PostLoginRedirect />}>
- <div class="flex items-center justify-center size-full p-8 overflow-hidden relative">
+ <Show when={!userInfo()?.authenticated} fallback={<PostAuthGate />}>
+ <div class="flex items-center justify-center size-full overflow-hidden relative">
<style>{
/*css*/ `
- @keyframes login-fade-up {
- from { opacity: 0; transform: translateY(8px); }
- to { opacity: 1; transform: translateY(0); }
+ @keyframes ln-card-in {
+ from { opacity: 0; transform: translateY(14px) scale(0.985); }
+ to { opacity: 1; transform: translateY(0) scale(1); }
}
- .login-card {
- animation: login-fade-up 300ms ease-out both;
- }
- .login-stagger > * {
- animation: login-fade-up 300ms ease-out both;
+ .ln-card { animation: ln-card-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
+
+ /* Override browser autofill yellow with our surface/ink palette */
+ .ln-input:-webkit-autofill,
+ .ln-input:-webkit-autofill:hover,
+ .ln-input:-webkit-autofill:focus,
+ .ln-input:-webkit-autofill:active {
+ -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
+ -webkit-text-fill-color: var(--color-ink);
+ caret-color: var(--color-ink);
+ transition: background-color 5000s ease-in-out 0s;
}
- .login-stagger > *:nth-child(1) { animation-delay: 50ms; }
- .login-stagger > *:nth-child(2) { animation-delay: 120ms; }
- .login-stagger > *:nth-child(3) { animation-delay: 190ms; }
- .login-stagger > *:nth-child(4) { animation-delay: 260ms; }
- .login-stagger > *:nth-child(5) { animation-delay: 330ms; }
`
}</style>
- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">
- <PcNoiseGrid
- cellSize={30}
- warp={0}
- crunch={0.2}
- freq={0.001}
- size={[0, 0.3]}
- rounding={0}
- fill={0}
- stroke={1}
- speed={[0.017, 0.209]}
- />
- </div>
- <div class="w-full max-w-105 login-card">
- <Surface depth={1}>
- <div class="login-stagger">
- <div
- class={cn(
- 'flex items-center justify-center py-10',
- virtualKeyboardVisible() && 'hidden'
- )}
+ <NoiseBackground />
+
+ <div class="relative z-10 w-full max-w-sm sm:max-w-lg ln-card">
+ <div class="px-4 sm:px-8 flex flex-col gap-12">
+ <div class="flex flex-col gap-8">
+ <Show when={!virtualKeyboardVisible()}>
+ <div class="flex flex-col gap-1.5">
+ <LogoIcon class="mb-2 size-9 text-accent" />
+ <h1 class="font-semibold tracking-tight text-ink text-2xl">
+ Welcome to Macro
+ </h1>
+ <p class="text-sm text-ink-muted">
+ The open source workspace
+ </p>
+ </div>
+ </Show>
+
+ <Stepper
+ step={stepIndex()}
+ transition={Stepper.transitions.scale}
+ >
+ <Stepper.Step>
+ <LoginPicker
+ setStage={onStageChange}
+ signupMode={props.signupMode}
+ />
+ </Stepper.Step>
+ <Stepper.Step>
+ <EmailFormNew setStage={onStageChange} onBack={onBack} />
+ </Stepper.Step>
+ <Stepper.Step>
+ <VerifyFormNew setStage={onStageChange} onBack={onBack} />
+ </Stepper.Step>
+ </Stepper>
+ </div>
+
+ <div class="text-center text-xs text-ink/50 wrap-break-word">
+ By continuing, you agree to our{' '}
+ <a
+ class="underline underline-offset-2 hover:text-ink focus-visible:text-ink"
+ href="/terms"
+ >
+ terms
+ </a>{' '}
+ and{' '}
+ <a
+ class="underline underline-offset-2 hover:text-ink focus-visible:text-ink"
+ href="/privacy"
>
- <LogoIcon class="size-20 text-accent" />
- </div>
- <div class="w-full">
- <Switch>
- <Match when={stage() === Stage.None}>
- <LoginOptions setStage={onStageChange} />
- </Match>
- <Match when={stage() === Stage.Email}>
- <EmailForm setStage={onStageChange} />
- </Match>
- <Match when={stage() === Stage.Verify}>
- <VerifyForm setStage={onStageChange} />
- </Match>
- </Switch>
- </div>
+ privacy policy
+ </a>
+ .
</div>
- </Surface>
+ </div>
</div>
</div>
</Show>
diff --git a/apps/web/src/features/auth/LoginNew.tsx b/apps/web/src/features/auth/LoginNew.tsx
deleted file mode 100644
index c108122570..0000000000
--- a/apps/web/src/features/auth/LoginNew.tsx
+++ /dev/null
@@ -1,643 +0,0 @@
-import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
-import { OnboardingFlow } from '@app/features/setup/flow/OnboardingFlow';
-import { NoiseBackground } from '@app/features/setup/flow/shared';
-import { useOnboardingV4Flag } from '@app/features/setup/flow/useOnboardingV4Flag';
-import { useAnalytics } from '@app/lib/analytics/analytics-context';
-import { GOOGLE_GMAIL_IDP } from '@core/auth/email';
-import { LoadingBlock } from '@core/component/LoadingBlock';
-import { useEmailLinks } from '@core/email-link';
-import { isMobile } from '@core/mobile/isMobile';
-import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
-import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
-import { unsetTokenPromise } from '@core/util/fetchWithToken';
-import { getNativeMobilePlatform } from '@core/util/platform';
-import IconApple from '@icon/macro-apple.svg';
-import IconGoogle from '@icon/macro-google.svg';
-import LogoIcon from '@icon/macro-logo.svg';
-import ArrowLeft from '@phosphor/arrow-left.svg';
-import ArrowRight from '@phosphor/arrow-right.svg';
-import { useUserInfo } from '@queries/auth';
-import {
- invalidateAllAfterLogin,
- useUserInfoQuery,
-} from '@queries/auth/user-info';
-import { authServiceClient } from '@service-auth/client';
-import {
- action,
- useAction,
- useNavigate,
- useSearchParams,
- useSubmission,
-} from '@solidjs/router';
-import { Button, cn } from '@ui';
-import { Stepper } from '@ui/components/Stepper';
-import { detect } from 'detect-browser';
-import {
- createEffect,
- createMemo,
- createSignal,
- type JSX,
- on,
- onCleanup,
- onMount,
- Show,
- untrack,
-} from 'solid-js';
-import {
- autoLoginCode,
- sendEmailCode,
- sentEmailCode,
- useResetEmailCode,
-} from './EmailForm';
-import { OtpInput } from './OtpInput';
-import { Stage } from './Shared';
-import { useSsoLogin } from './useSsoLogin';
-
-function PostLoginRedirect() {
- const navigate = useNavigate();
-
- // Login init is owned by the per-method handlers (the session-token effect and
- // onComplete); this redirect only navigates, so login doesn't fire init twice.
- onMount(() => {
- navigate('/', { replace: true });
- });
-
- return <LoadingBlock />;
-}
-
-/**
- * Where login and onboarding meet: once authenticated, first-time desktop
- * users continue straight into the onboarding steps IN PLACE — same page,
- * no redirect — while everyone else proceeds into the app. This keeps
- * /login a single surface that decides what the user needs next.
- */
-function PostAuthGate() {
- const userInfoQuery = useUserInfoQuery();
- const onboardingV4 = useOnboardingV4Flag();
-
- const isFirstTimeDesktopUser = () =>
- !isMobile() &&
- !isNativeMobilePlatform() &&
- userInfoQuery.data?.authenticated === true &&
- userInfoQuery.data.tutorialComplete === false;
-
- const needsOnboarding = () =>
- onboardingV4().enabled && isFirstTimeDesktopUser();
-
- // Don't redirect into the app while the gate is still unknown: a first-time
- // user would land on home for a beat and then get yanked to /onboarding.
- const waitingOnFlag = () =>
- onboardingV4().loading && isFirstTimeDesktopUser();
-
- return (
- <Show when={!waitingOnFlag()} fallback={<LoadingBlock />}>
- <Show when={needsOnboarding()} fallback={<PostLoginRedirect />}>
- <OnboardingFlow />
- </Show>
- </Show>
- );
-}
-
-function LoginPicker(props: { setStage: (next: Stage) => void }) {
- const startSsoLogin = useSsoLogin();
- // Apple sign-in is iOS-only: it's required there for App Store review,
- // and intentionally absent on desktop.
- const showApple = getNativeMobilePlatform() === 'ios';
-
- return (
- <div class="flex flex-col gap-3">
- <Button
- variant="cta"
- autofocus
- onClick={() => startSsoLogin(GOOGLE_GMAIL_IDP)}
- >
- <IconGoogle />
- Continue with Google
- </Button>
-
- <Show when={showApple}>
- <Button
- variant="base"
- class="bg-surface"
- onClick={() => startSsoLogin('Apple')}
- >
- <IconApple />
- Continue with Apple
- </Button>
- </Show>
-
- <Button
- variant="base"
- class="bg-surface"
- onClick={() => props.setStage(Stage.Email)}
- >
- Continue with email
- </Button>
- </div>
- );
-}
-
-function FormInput(props: {
- id: string;
- type?: string;
- placeholder?: string;
- required?: boolean;
- value?: string;
- inputMode?: 'text' | 'numeric';
- pattern?: string;
- maxLength?: number;
- autoFocus?: boolean;
- monospace?: boolean;
- centered?: boolean;
- class?: string;
- onInput?: JSX.ChangeEventHandlerUnion<HTMLInputElement, Event>;
-}) {
- let inputEl: HTMLInputElement | undefined;
- onMount(() => {
- if (props.autoFocus === false) return;
- // The Stepper's outin Transition resolves this step's JSX (firing onMount)
- // before attaching it to the document, so the input is still detached
- // here. Poll until it's connected, then focus.
- const focusWhenConnected = () => {
- if (!inputEl) return;
- if (inputEl.isConnected) inputEl.focus({ preventScroll: true });
- else requestAnimationFrame(focusWhenConnected);
- };
- focusWhenConnected();
- });
- return (
- <input
- ref={(el) => (inputEl = el)}
- id={props.id}
- name={props.id}
- type={props.type ?? 'text'}
- inputMode={props.inputMode}
- pattern={props.pattern}
- placeholder={props.placeholder}
- value={props.value ?? ''}
- required={props.required ?? true}
- maxLength={props.maxLength}
- autocomplete={props.id}
- onInput={props.onInput}
- class={cn(
- 'ln-input w-full px-4 py-3 rounded-lg border border-edge bg-surface text-sm text-ink placeholder:text-ink-placeholder focus:border-accent focus:outline-none transition-colors',
- 'user-invalid:border-failure',
- props.monospace && 'font-mono tracking-[0.4em] text-base',
- props.centered && 'text-center',
- props.class
- )}
- />
- );
-}
-
-function FormError(props: { msg?: string }) {
- return (
- <Show when={props.msg}>
- <p role="alert" class="text-xs text-failure leading-snug">
- {props.msg}
- </p>
- </Show>
- );
-}
-
-function EmailFormNew(props: {
- setStage: (next: Stage) => void;
- onBack: () => void;
-}) {
- const [isPasswordLogin, setIsPasswordLogin] = createSignal(false);
- const submission = useSubmission(sendEmailCode);
- const send = useAction(sendEmailCode);
- const [searchParams] = useSearchParams();
- const searchParamsEmail = untrack(() => {
- const email = searchParams.email;
- if (typeof email === 'string') return email;
- });
-
- // Dev builds auto-start the flow for `?email=` links (the seeder prints
- // them per persona); combined with the local backend returning the code,
- // opening the link logs straight in.
- createEffect(() => {
- if (
- import.meta.env.DEV &&
- searchParamsEmail &&
- !submission.pending &&
- !submission.result &&
- !submission.error
- ) {
- const formData = new FormData();
- formData.append('email', searchParamsEmail);
- send(formData);
- }
- });
-
- createEffect(() => {
- if (sentEmailCode(submission.result)) {
- props.setStage(Stage.Verify);
- } else if (submission.result === 'isPasswordLogin') {
- setIsPasswordLogin(true);
- } else if (submission.result === 'LoggedIn') {
- props.setStage(Stage.Done);
- }
- });
-
- return (
- <form
- action={sendEmailCode}
- method="post"
- noValidate={false}
- class="flex flex-col gap-3"
- >
- <p class="text-xs text-ink-muted leading-snug">
- We’ll send a one-time code to verify.
- </p>
- <FormInput
- id="email"
- type="email"
- placeholder="[email protected]"
- value={searchParamsEmail}
- />
- <Show when={isPasswordLogin()}>
- <FormInput
- id="password"
- type="password"
- placeholder="Password"
- required={isPasswordLogin()}
- />
- </Show>
- <FormError msg={submission.error?.message} />
- <Button variant="cta" type="submit" disabled={submission.pending}>
- Continue
- <ArrowRight class="size-4" />
- </Button>
- <Button variant="base" class="bg-surface" onClick={props.onBack}>
- <ArrowLeft class="size-4" />
- Back to sign in
- </Button>
- </form>
- );
-}
-
-const verifyCode = action(async (formData: FormData) => {
- const code = formData.get('one-time-code');
- if (typeof code !== 'string') throw new Error('Invalid code');
- const email = formData.get('email');
- if (typeof email !== 'string') throw new Error('Invalid email');
-
- const result = await authServiceClient.passwordlessCallback({ code, email });
- if (result.isErr()) {
- if (result.error.some((err) => err.code === 'UNAUTHORIZED')) {
- throw new Error('Invalid code.');
- }
- throw new Error('Unable to perform verification.');
- }
-
- return true;
-}, 'verify-code-login-new');
-
-const RESEND_TIMER = 45;
-
-function VerifyFormNew(props: {
- setStage: (next: Stage) => void;
- onBack: () => void;
-}) {
- const [code, setCode] = createSignal('');
- const [resendError, setResendError] = createSignal<string>();
- const [showResendCode, setShowResendCode] = createSignal(false);
- const [resendTimer, setResendTimer] = createSignal(RESEND_TIMER);
- const submission = useSubmission(verifyCode);
- const emailSubmission = useSubmission(sendEmailCode);
- const resend = useAction(sendEmailCode);
- const submit = useAction(verifyCode);
-
- const email = () => emailSubmission.input?.[0].get('email') as string;
-
- // Local backends return the code with the email step; submit it
- // automatically so seeded persona logins are one click.
- createEffect(() => {
- const code = autoLoginCode(emailSubmission.result);
- if (
- code &&
- !submission.pending &&
- !submission.result &&
- !submission.error
- ) {
- const formData = new FormData();
- formData.append('email', email());
- formData.append('one-time-code', code);
- submit(formData);
- }
- });
-
- createEffect(() => {
- if (!showResendCode()) {
- const timer = setTimeout(() => {
- setResendTimer(0);
- setShowResendCode(true);
- }, RESEND_TIMER * 1000);
- const pTimer = setInterval(
- () => setResendTimer((t) => (t > 0 ? t - 1 : 0)),
- 1000
- );
- onCleanup(() => {
- clearTimeout(timer);
- clearInterval(pTimer);
- });
- }
- });
-
- const handleResendCode = async () => {
- submission.clear();
- setResendError();
- setResendTimer(RESEND_TIMER);
- setShowResendCode(false);
- const formData = new FormData();
- formData.append('email', email());
- try {
- await resend(formData);
- } catch (e) {
- console.error(e);
- setResendTimer(0);
- setShowResendCode(true);
- setResendError(
- e instanceof Error
- ? e.message
- : 'Failed to resend code. Please try again.'
- );
- }
- };
-
- createEffect(() => {
- if (submission.result) {
- props.setStage(Stage.Done);
- const url = new URL(window.location.href);
- const sp = new URLSearchParams(url.search);
- const referral = sp.get('referral');
- if (referral) window.location.href = `/app?referral=${referral}`;
- }
- });
-
- let formEl: HTMLFormElement | undefined;
-
- return (
- <form
- ref={formEl}
- action={verifyCode}
- method="post"
- class="flex flex-col gap-3"
- >
- <input type="hidden" name="email" value={email() ?? ''} />
- <input type="hidden" name="one-time-code" value={code()} />
- <p class="text-xs text-ink-muted leading-snug">
- Enter the 6-digit code we sent to{' '}
- <span class="text-ink font-medium break-all">{email()}</span>.
- </p>
- <OtpInput
- value={code()}
- disabled={submission.pending}
- onInput={setCode}
- onComplete={(value) => {
- const formData = new FormData(formEl);
- formData.set('email', email());
- formData.set('one-time-code', value);
- submit(formData);
- }}
- />
- <p class="text-center text-xs text-ink-muted" aria-live="polite">
- Didn't receive a code?{' '}
- <button
- type="button"
- onClick={handleResendCode}
- disabled={
- emailSubmission.pending || submission.pending || !showResendCode()
- }
- class="font-medium text-ink transition-colors hover:text-ink-muted disabled:text-ink-extra-muted"
- >
- <Show when={resendTimer() > 0} fallback="Resend">
- Resend ({resendTimer()})
- </Show>
- </button>
- </p>
- <FormError msg={submission.error?.message ?? resendError()} />
- {/* The visible pattern-validated input is gone (the code lives in a
- hidden field, which browsers exempt from constraint validation), so
- gate submission here instead of round-tripping partial codes. */}
- <Button
- variant="cta"
- type="submit"
- disabled={submission.pending || code().length !== 6}
- >
- Verify
- <ArrowRight class="size-4" />
- </Button>
- <Button variant="base" class="bg-surface" onClick={props.onBack}>
- <ArrowLeft class="size-4" />
- Change email
- </Button>
- </form>
- );
-}
-
-export function LoginNew() {
- const [searchParams] = useSearchParams();
- const [stage, setStage] = createSignal(
- searchParams.email ? Stage.Email : Stage.None
- );
- const userInfo = useUserInfo();
- const analytics = useAnalytics();
- const authenticatedUserId = createMemo(() => {
- const user = userInfo();
- return user?.authenticated ? user.id : undefined;
- });
-
- onMount(() => {
- analytics.pageView('login');
- });
-
- const identifyUser = () => {
- const user = userInfo();
-
- if (!user || !user.authenticated) return;
-
- const platform = detect(navigator.userAgent);
- analytics.identify(user.id, {
- email: user.email,
- os: platform?.os?.replaceAll(' ', ''),
- });
- };
-
- createEffect(
- on(authenticatedUserId, (userId) => {
- if (userId) identifyUser();
- })
- );
-
- createEffect(() => {
- // token may be an array if the redirect URL contained duplicate token params;
- // take the last one as it is the most recently appended by the auth service
- const rawToken = searchParams.token;
- const session_code = Array.isArray(rawToken)
- ? rawToken[rawToken.length - 1]
- : rawToken;
- if (session_code && typeof session_code === 'string') {
- unsetTokenPromise();
- authServiceClient.sessionLogin({ session_code }).then(async (res) => {
- if (res.isOk()) {
- await invalidateAllAfterLogin();
- await initEmailLink().match(
- () => {},
- (err) => {
- if (err.tag !== 'AlreadyInitialized') {
- console.error('Failed to init email link on login', err);
- }
- }
- );
- }
- });
- }
- });
-
- const { initEmailLink } = useEmailLinks();
-
- const onComplete = async () => {
- unsetTokenPromise();
- await invalidateAllAfterLogin();
- await initEmailLink().match(
- () => {},
- (err) => {
- if (err.tag !== 'AlreadyInitialized') {
- console.error('Failed to init email link on login', err);
- }
- }
- );
- const user = userInfo();
-
- if (!user || !user.authenticated) return;
-
- analytics.track('login', {
- method: 'email',
- });
- identifyUser();
- };
-
- onCleanup(() => {
- setStage(Stage.Email);
- });
-
- const onStageChange = (next: Stage) => {
- if (next === Stage.Done) {
- onComplete();
- }
- setStage(next);
- };
-
- const stepIndex = () =>
- stage() === Stage.None ? 0 : stage() === Stage.Email ? 1 : 2;
-
- const emailSubmission = useSubmission(sendEmailCode);
- const verifySubmission = useSubmission(verifyCode);
- const resetEmailCode = useResetEmailCode(setStage);
-
- const onBack = () => {
- if (stage() === Stage.Verify) {
- verifySubmission.clear();
- resetEmailCode();
- } else if (stage() === Stage.Email) {
- emailSubmission.clear();
- setStage(Stage.None);
- }
- };
-
- return (
- <Show when={!userInfo()?.authenticated} fallback={<PostAuthGate />}>
- <div class="flex items-center justify-center size-full overflow-hidden relative">
- <style>{
- /*css*/ `
- @keyframes ln-card-in {
- from { opacity: 0; transform: translateY(14px) scale(0.985); }
- to { opacity: 1; transform: translateY(0) scale(1); }
- }
- .ln-card { animation: ln-card-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both; }
-
- /* Override browser autofill yellow with our surface/ink palette */
- .ln-input:-webkit-autofill,
- .ln-input:-webkit-autofill:hover,
- .ln-input:-webkit-autofill:focus,
- .ln-input:-webkit-autofill:active {
- -webkit-box-shadow: 0 0 0 1000px var(--color-surface) inset;
- -webkit-text-fill-color: var(--color-ink);
- caret-color: var(--color-ink);
- transition: background-color 5000s ease-in-out 0s;
- }
- `
- }</style>
-
- <NoiseBackground />
-
- <div class="relative z-10 w-full max-w-sm sm:max-w-lg ln-card">
- <div class="px-4 sm:px-8 flex flex-col gap-12">
- <div class="flex flex-col gap-8">
- <Show when={!virtualKeyboardVisible()}>
- <div class="flex flex-col gap-1.5">
- <LogoIcon class="mb-2 size-9 text-accent" />
- <h1 class="font-semibold tracking-tight text-ink text-2xl">
- Welcome to Macro
- </h1>
- <p class="text-sm text-ink-muted">
- The open source workspace
- </p>
- </div>
- </Show>
-
- <Stepper
- step={stepIndex()}
- transition={Stepper.transitions.scale}
- >
- <Stepper.Step>
- <div class="flex flex-col gap-8">
- <LoginPicker setStage={onStageChange} />
- <div class="flex justify-center gap-2 text-sm">
- <div class="text-ink/50">New to Macro?</div>
- <a
- class="text-ink hover:text-accent focus-visible:text-accent"
- href={`${ROUTER_BASE_CONCAT}signup`}
- tabindex={0}
- >
- Create an account
- </a>
- </div>
- </div>
- </Stepper.Step>
- <Stepper.Step>
- <EmailFormNew setStage={onStageChange} onBack={onBack} />
- </Stepper.Step>
- <Stepper.Step>
- <VerifyFormNew setStage={onStageChange} onBack={onBack} />
- </Stepper.Step>
- </Stepper>
- </div>
-
- <div class="flex flex-col text-center text-xs text-ink-muted">
- <div class="text-ink/50 wrap-break-word">
- By continuing, you agree to our{' '}
- <a
- class="underline underline-offset-2 hover:text-ink focus-visible:text-ink"
- href="/terms"
- >
- terms
- </a>{' '}
- and{' '}
- <a
- class="underline underline-offset-2 hover:text-ink focus-visible:text-ink"
- href="/privacy"
- >
- privacy policy
- </a>
- .
- </div>
- </div>
- </div>
- </div>
- </div>
- </Show>
- );
-}
diff --git a/apps/web/src/features/auth/LoginOptions.tsx b/apps/web/src/features/auth/LoginOptions.tsx
deleted file mode 100644
index 2e948fa2c9..0000000000
--- a/apps/web/src/features/auth/LoginOptions.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';
-import { GOOGLE_GMAIL_IDP } from '@core/auth/email';
-import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { getNativeMobilePlatform } from '@core/util/platform';
-import IconApple from '@icon/macro-apple.svg';
-import IconGoogle from '@icon/macro-google.svg';
-import IconMail from '@icon/macro-mail.svg';
-import { type JSX, Show } from 'solid-js';
-import { Stage } from './Shared';
-import { useSsoLogin } from './useSsoLogin';
-
-function LoginOption(props: {
- icon: JSX.Element;
- label: string;
- onClick: () => void;
-}) {
- return (
- <div
- onClick={(_e) => {
- if (isTouchDevice()) return;
- props.onClick();
- }}
- // Using onPointerDown so that on touch device able to interact with button before closing virtual keyboard
- onPointerDown={(e) => {
- if (!isTouchDevice()) return;
- e.stopPropagation();
- e.preventDefault();
- props.onClick();
- }}
- class="grid items-center justify-center p-4 border-b border-edge-muted [transition:color_var(--transition)] hover:bg-hover/60 hover:text-accent hover:transition-none"
- >
- <div class="flex gap-2.5 items-center justify-center">
- {props.icon}
- <div class="whitespace-nowrap">{props.label}</div>
- </div>
- </div>
- );
-}
-
-export function LoginOptions(props: {
- setStage: (next: Stage) => void;
- signupMode?: boolean;
-}) {
- const startSsoLogin = useSsoLogin({ signupMode: props.signupMode });
-
- return (
- <div class="grid select-none border-t border-edge-muted">
- <Show when={getNativeMobilePlatform() === 'ios'}>
- <LoginOption
- icon={<IconApple />}
- label="Continue with Apple"
- onClick={() => startSsoLogin('Apple')}
- />
- </Show>
-
- <LoginOption
- icon={<IconGoogle />}
- label={
- props.signupMode ? 'Sign up with Google' : 'Continue with Google'
- }
- onClick={() => startSsoLogin(GOOGLE_GMAIL_IDP)}
- />
-
- <Show when={!props.signupMode}>
- <LoginOption
- icon={<IconMail />}
- label="Continue with Email"
- onClick={() => props.setStage(Stage.Email)}
- />
- </Show>
-
- <Show when={props.signupMode}>
- <div class="p-4 text-center text-xs text-ink/50">
- <a
- class="underline hover:text-ink/70"
- href={`${ROUTER_BASE_CONCAT}login`}
- >
- Existing user? Log in
- </a>
- </div>
- </Show>
-
- <div class="p-4 text-center text-xs text-ink/50">
- By signing up, you agree to our
- <br />
- <a class="underline hover:text-ink/70" href="/terms">
- terms
- </a>{' '}
- and{' '}
- <a class="underline hover:text-ink/70" href="/privacy">
- privacy policy
- </a>
- .
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/features/auth/Shared.tsx b/apps/web/src/features/auth/Shared.tsx
index c5949590f6..30d9040624 100644
--- a/apps/web/src/features/auth/Shared.tsx
+++ b/apps/web/src/features/auth/Shared.tsx
@@ -1,8 +1,3 @@
-import { authServiceClient } from '@service-auth/client';
-import { cn } from '@ui';
-import type { JSX } from 'solid-js';
-import { createSignal, onMount, Show } from 'solid-js';
-
export function setCookie(name: string, value: string, days: number) {
const expires = days
? `; expires=${new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString()}`
@@ -10,63 +5,9 @@ export function setCookie(name: string, value: string, days: number) {
document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/`;
}
-const _assignABGroup = async () => {
- const randomGroup = Math.random() < 0.5 ? 'A' : 'B';
- await authServiceClient.setGroup({ group: randomGroup });
- return randomGroup;
-};
-
export enum Stage {
Verify = 'verify',
Email = 'email',
Done = 'done',
None = 'none',
}
-
-export function Input(props: {
- onInput?: JSX.ChangeEventHandlerUnion<HTMLInputElement, Event>;
- inputMode?: 'text' | 'numeric';
- textCenter?: boolean;
- placeholder?: string;
- readOnly?: boolean;
- required?: boolean;
- value?: string;
- type?: string;
- id: string;
-}) {
- const [el, setEl] = createSignal<HTMLInputElement>();
- onMount(() => {
- setTimeout(() => {
- el()?.focus();
- }, 1);
- });
- return (
- <input
- class={cn(
- 'appearance-none disabled:bg-edge block w-full shadow-none placeholder-placeholder sm:text-sm',
- props.textCenter && 'text-center'
- )}
- required={props.required ?? true}
- placeholder={props.placeholder}
- type={props.type || 'text'}
- inputMode={props.inputMode}
- readOnly={props.readOnly}
- value={props.value ?? ''}
- onInput={props.onInput}
- autocomplete={props.id}
- name={props.id}
- id={props.id}
- ref={setEl}
- />
- );
-}
-
-export function ErrorMsg(props: { msg?: string }) {
- return (
- <Show when={props.msg}>
- <div class="grid items-center justify-center p-4 border-b border-edge-muted text-sm text-failure">
- {props.msg}
- </div>
- </Show>
- );
-}
diff --git a/apps/web/src/features/auth/Signup.tsx b/apps/web/src/features/auth/Signup.tsx
deleted file mode 100644
index 02f221ddd2..0000000000
--- a/apps/web/src/features/auth/Signup.tsx
+++ /dev/null
@@ -1,99 +0,0 @@
-import { useAnalytics } from '@app/lib/analytics/analytics-context';
-import { LoadingBlock } from '@core/component/LoadingBlock';
-import { PcNoiseGrid } from '@core/component/PcNoiseGrid';
-import { toast } from '@core/component/Toast/Toast';
-import { useEmailLinks } from '@core/email-link';
-import LogoIcon from '@icon/macro-logo.svg';
-import { useUserInfo } from '@queries/auth';
-import { useNavigate } from '@solidjs/router';
-import { Surface } from '@ui';
-import { onMount, Show } from 'solid-js';
-import { LoginOptions } from './LoginOptions';
-import type { Stage } from './Shared';
-
-function PostSignupRedirect() {
- const navigate = useNavigate();
- const { initEmailLink } = useEmailLinks();
-
- onMount(async () => {
- await initEmailLink().match(
- () => {},
- (err) => {
- if (err.tag !== 'AlreadyInitialized') {
- toast.alert('Failed to connect email', {
- subtext: 'Select email permissions on sign-in to enable',
- });
- }
- }
- );
- navigate('/', {
- replace: true,
- });
- });
-
- return <LoadingBlock />;
-}
-
-export function Signup() {
- const userInfo = useUserInfo();
- const analytics = useAnalytics();
-
- onMount(() => {
- analytics.pageView('signup');
- });
-
- return (
- <Show when={!userInfo()?.authenticated} fallback={<PostSignupRedirect />}>
- <div class="flex items-center justify-center size-full p-8 overflow-hidden relative">
- <style>
- {
- /*css*/ `
- @keyframes login-fade-up {
- from { opacity: 0; transform: translateY(8px); }
- to { opacity: 1; transform: translateY(0); }
- }
- .login-card {
- animation: login-fade-up 300ms ease-out both;
- }
- .login-stagger > * {
- animation: login-fade-up 300ms ease-out both;
- }
- .login-stagger > *:nth-child(1) { animation-delay: 50ms; }
- .login-stagger > *:nth-child(2) { animation-delay: 120ms; }
- .login-stagger > *:nth-child(3) { animation-delay: 190ms; }
- .login-stagger > *:nth-child(4) { animation-delay: 260ms; }
- `
- }
- </style>
- <div class="inset-0 absolute text-edge bg-surface opacity-10 -z-1">
- <PcNoiseGrid
- cellSize={30}
- warp={0}
- crunch={0.2}
- freq={0.001}
- size={[0, 0.3]}
- rounding={0}
- fill={0}
- stroke={1}
- speed={[0.017, 0.209]}
- />
- </div>
-
- <div class="w-full max-w-105 login-card">
- <Surface depth={1} class="login-stagger">
- <div class="flex items-center justify-center py-10">
- <LogoIcon class="size-20 text-accent" />
- </div>
- <div class="text-center text-lg font-medium">Welcome to Macro</div>
- <div class="px-8 pb-4 pt-2 text-center text-sm/relaxed text-ink/60">
- Sign up with Google to sync your inbox and set up your workspace.
- </div>
- <div class="w-full">
- <LoginOptions signupMode setStage={(_stage: Stage) => {}} />
- </div>
- </Surface>
- </div>
- </div>
- </Show>
- );
-}
diff --git a/apps/web/src/features/auth/VerifyForm.tsx b/apps/web/src/features/auth/VerifyForm.tsx
deleted file mode 100644
index 28a12ec9ab..0000000000
--- a/apps/web/src/features/auth/VerifyForm.tsx
+++ /dev/null
@@ -1,180 +0,0 @@
-import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
-import ArrowLeft from '@phosphor/arrow-left.svg';
-import ArrowRight from '@phosphor/arrow-right.svg';
-import { authServiceClient } from '@service-auth/client';
-import { action, useAction, useSubmission } from '@solidjs/router';
-import { cn } from '@ui';
-import { createEffect, createSignal, onCleanup, Show } from 'solid-js';
-import { sendEmailCode, useResetEmailCode } from './EmailForm';
-import { ErrorMsg, Input, Stage } from './Shared';
-
-const verifyCode = action(async (formData: FormData) => {
- const code = formData.get('one-time-code');
- if (typeof code !== 'string') throw new Error('Invalid code');
-
- const email = formData.get('email');
- if (typeof email !== 'string') throw new Error('Invalid email');
-
- const result = await authServiceClient.passwordlessCallback({
- code,
- email,
- });
- if (result.isErr()) {
- if (
- result.isErr() &&
- result.error.some((error) => error.code === 'UNAUTHORIZED')
- ) {
- throw new Error('Invalid code.');
- }
- throw new Error('Unable to perform verification.');
- }
-
- return true;
-}, 'verify-code');
-
-const RESEND_TIMER = 45;
-
-export function VerifyForm(props: { setStage: (next: Stage) => void }) {
- const [resendError, setResendError] = createSignal<string>();
- const [showResendCode, setShowResendCode] = createSignal(false);
- const [resendTimer, setResendTimer] = createSignal(RESEND_TIMER);
- const submission = useSubmission(verifyCode);
- const emailSubmission = useSubmission(sendEmailCode);
- const resend = useAction(sendEmailCode);
- const submit = useAction(verifyCode);
-
- const email = () => emailSubmission.input?.[0].get('email') as string;
-
- createEffect(() => {
- if (!showResendCode()) {
- const timer = setTimeout(() => {
- setResendTimer(0);
- setShowResendCode(true);
- }, RESEND_TIMER * 1000);
- const pTimer = setInterval(
- () => setResendTimer((t) => (t > 0 ? t - 1 : 0)),
- 1000
- );
- onCleanup(() => {
- clearTimeout(timer);
- clearInterval(pTimer);
- });
- }
- });
-
- const handleResendCode = async () => {
- submission.clear();
- setResendError();
- setResendTimer(RESEND_TIMER);
- setShowResendCode(false);
- const formData = new FormData();
- formData.append('email', email());
- try {
- await resend(formData);
- } catch (e) {
- console.error(e);
- setResendTimer(0);
- setShowResendCode(true);
- setResendError(
- e instanceof Error
- ? e.message
- : 'Failed to resend code. Please try again.'
- );
- }
- };
-
- createEffect(() => {
- if (submission.result) {
- props.setStage(Stage.Done);
-
- const url = new URL(window.location.href);
- const searchParams = new URLSearchParams(url.search);
- const referral = searchParams.get('referral');
- if (referral) window.location.href = `/app?referral=${referral}`;
- }
- });
-
- const resetEmailCode = useResetEmailCode(props.setStage);
- let formEl: HTMLFormElement | undefined;
-
- return (
- <div>
- <form ref={formEl} action={verifyCode} method="post" class="mt-1">
- <div
- class={cn(
- 'flex items-center justify-center py-4 px-6 border-b border-edge-muted',
- virtualKeyboardVisible() && 'border-t border-edge-muted'
- )}
- >
- <label
- for="one-time-code"
- class="block text-sm text-ink-muted text-center"
- >
- A 6-digit code has been sent to
- <br />
- <span class="underline text-ink">{email()}</span>
- </label>
- </div>
-
- <div class="border-b border-edge-muted py-4 px-6 flex flex-none justify-between items-center">
- <Input
- id="one-time-code"
- type="text"
- inputMode="numeric"
- placeholder="Activation Code"
- onInput={(x) => {
- if (x.currentTarget.value.length === 6) {
- const formData = new FormData(formEl);
- formData.set('email', email());
- submit(formData);
- }
- }}
- />
- <button
- class={cn(
- 'inline-block font-medium text-accent hover:text-accent/80 transition',
- showResendCode()
- ? 'opacity-100'
- : 'opacity-50 pointer-events-none',
- (emailSubmission.pending || submission.pending) &&
- 'opacity-50 pointer-events-none'
- )}
- disabled={
- emailSubmission.pending || submission.pending || !showResendCode()
- }
- onClick={handleResendCode}
- type="button"
- >
- <Show when={resendTimer() > 0} fallback="Resend">
- Resend({resendTimer()}s)
- </Show>
- </button>
- </div>
-
- <div class="border-b border-edge-muted py-4 px-6 flex flex-none justify-between items-center">
- <button
- class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
- onClick={resetEmailCode}
- type="button"
- >
- <ArrowLeft class="size-5" />
- <span>Back</span>
- </button>
-
- <button
- class="hover:text-accent hover:transition-none transition-colors duration-300 grid grid-cols-[min-content_min-content] gap-1.5 items-center w-min"
- type="submit"
- disabled={submission.pending}
- >
- <span>Continue</span>
- <ArrowRight class="size-5" />
- </button>
- </div>
-
- <ErrorMsg msg={submission.error?.message} />
- </form>
-
- <ErrorMsg msg={resendError()} />
- </div>
- );
-}
diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.ts
index 58480eac5a..dfba426d77 100644
--- a/apps/web/src/lib/core/constant/featureFlags.ts
+++ b/apps/web/src/lib/core/constant/featureFlags.ts
@@ -410,8 +410,6 @@ export function ENABLE_CALLS(): boolean {
export const ENABLE_NEW_ONBOARDING_OVERRIDE = DEV_MODE_ENV ? true : undefined;
-export const ENABLE_NEW_LOGIN_OVERRIDE = DEV_MODE_ENV ? true : undefined;
-
export const ENABLE_INVITE_TEAM_ONBOARDING_OVERRIDE = DEV_MODE_ENV
? true
: undefined;
diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsx
index f28d31b017..dfa0ff4cb8 100644
--- a/apps/web/src/routes/Root.tsx
+++ b/apps/web/src/routes/Root.tsx
@@ -5,7 +5,6 @@ import { Login } from '@app/features/auth/Login';
import { MobileAuthWelcome } from '@app/features/auth/mobile-onboarding/MobileAuthWelcome';
import { MobileOnboarding } from '@app/features/auth/mobile-onboarding/MobileOnboarding';
import { setCookie } from '@app/features/auth/Shared';
-import { Signup } from '@app/features/auth/Signup';
import { ChannelInviteAcceptance } from '@app/features/channel-invitations/ChannelInviteAcceptance';
import { GlobalShareInboxConflictDialog } from '@app/features/inbox/ShareInboxConflictDialog';
import { SearchProvider } from '@app/features/next-soup/search-context';
@@ -395,7 +394,7 @@ const ROUTES: RouteDefinition[] = [
},
{
path: '/signup',
- component: Signup,
+ component: () => <Login signupMode />,
},
{
path: CALLBACK_PATH,