Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Port auth routes and OAuth consent to shadcn (EVE-305) (#754)
Carter Smith9f129c192189
diff --git a/src/client/features/auth/AuthPage.tsx b/src/client/features/auth/AuthPage.tsxindex 3b7ba422..d714a1c5 100644--- a/src/client/features/auth/AuthPage.tsx+++ b/src/client/features/auth/AuthPage.tsx@@ -1,4 +1,13 @@import { z } from "zod";+import { Button } from "@/client/components/ui/button";+import {+ Card,+ CardContent,+ CardDescription,+ CardFooter,+ CardHeader,+ CardTitle,+} from "@/client/components/ui/card";import {getCurrentAuthRedirect,getOAuthSignedQuery,@@ -41,24 +50,26 @@ export function AuthMethodChooser({}) {return (<div className="space-y-3">- <button+ <Buttontype="button"- className="btn w-full border border-black/10 bg-white text-neutral-900 hover:border-black/20 hover:bg-neutral-50 disabled:bg-white disabled:text-neutral-500 disabled:opacity-70"+ variant="outline"+ className="w-full !bg-white !text-neutral-900 hover:!bg-neutral-50"onClick={onContinueWithGoogle}disabled={disabled || isBusy}><GoogleLogo />{isBusy ? "Opening Google..." : googleLabel}- </button>+ </Button>- <button+ <Buttontype="button"- className="btn w-full"+ variant="secondary"+ className="w-full"onClick={onContinueWithEmail}disabled={disabled || isBusy}>{emailLabel}- </button>+ </Button></div>);}@@ -98,25 +109,29 @@ export function AuthPageCard({footer?: React.ReactNode;}) {return (- <div className="w-full max-w-xs space-y-6">- <div className="text-center space-y-3">+ <Card className="w-full max-w-xs">+ <CardHeader className="text-center space-y-3"><imgsrc="/transparent-logo.png"alt="OpenSEO"className="mx-auto size-10 rounded-lg"/><div>- <h1 className="text-xl font-semibold">{title}</h1>+ <CardTitle className="text-xl">+ <h1>{title}</h1>+ </CardTitle>{helperText ? (- <p className="text-sm text-base-content/60 mt-1">{helperText}</p>+ <CardDescription className="mt-1">{helperText}</CardDescription>) : null}</div>- </div>+ </CardHeader>- {children}+ <CardContent className="space-y-4">{children}</CardContent>- {footer ? <div className="text-center">{footer}</div> : null}- </div>+ {footer ? (+ <CardFooter className="justify-center text-center">{footer}</CardFooter>+ ) : null}+ </Card>);}@@ -126,7 +141,7 @@ export function AuthPageShell({ children }: { children: React.ReactNode }) {// auto-margin child centers when it fits but stays fully reachable (top and// bottom) when it's taller than the viewport. Plain `justify-center` clips// the overflow with no way to scroll to it.- <div className="h-[100dvh] flex flex-col items-center overflow-y-auto p-4 bg-base-200">+ <div className="flex h-[100dvh] flex-col items-center overflow-y-auto bg-background p-4"><div className="m-auto flex w-full flex-col items-center">{children}</div></div>);diff --git a/src/client/features/auth/TurnstileWidget.tsx b/src/client/features/auth/TurnstileWidget.tsxindex 54b5554c..72441219 100644--- a/src/client/features/auth/TurnstileWidget.tsx+++ b/src/client/features/auth/TurnstileWidget.tsx@@ -13,6 +13,7 @@ type TurnstileApi = {element: HTMLElement,options: {sitekey: string;+ size: "compact";callback: (token: string) => void;"expired-callback"?: () => void;"error-callback"?: () => void;@@ -87,6 +88,7 @@ export function TurnstileWidget({}widgetIdRef.current = window.turnstile.render(containerRef.current, {sitekey: TURNSTILE_SITE_KEY,+ size: "compact",callback: (token) => onTokenRef.current(token),"expired-callback": () => onTokenRef.current(null),"error-callback": () => onTokenRef.current(null),diff --git a/src/client/features/auth/passwordSchema.ts b/src/client/features/auth/passwordSchema.tsnew file mode 100644index 00000000..a7c5b8f3--- /dev/null+++ b/src/client/features/auth/passwordSchema.ts@@ -0,0 +1,16 @@+import { z } from "zod";+import {+ HOSTED_PASSWORD_MAX_LENGTH,+ HOSTED_PASSWORD_MIN_LENGTH,+} from "@/lib/auth-options";++export const passwordSchema = z+ .string()+ .min(+ HOSTED_PASSWORD_MIN_LENGTH,+ `Password must be at least ${HOSTED_PASSWORD_MIN_LENGTH} characters.`,+ )+ .max(+ HOSTED_PASSWORD_MAX_LENGTH,+ `Password must be at most ${HOSTED_PASSWORD_MAX_LENGTH} characters.`,+ );diff --git a/src/client/features/auth/useGoogleAuth.ts b/src/client/features/auth/useGoogleAuth.tsnew file mode 100644index 00000000..7751fd64--- /dev/null+++ b/src/client/features/auth/useGoogleAuth.ts@@ -0,0 +1,48 @@+import { useState } from "react";+import { captureClientEvent } from "@/client/lib/posthog";+import { authClient } from "@/lib/auth-client";+import { toAuthCallbackURL } from "@/lib/auth-redirect";++export function useGoogleAuth({+ redirectTo,+ postSignupRedirect,+}: {+ redirectTo: string;+ postSignupRedirect?: string;+}) {+ const [isStarting, setIsStarting] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const isSignUp = postSignupRedirect !== undefined;++ async function start() {+ setError(null);+ setIsStarting(true);+ try {+ captureClientEvent(+ isSignUp ? "auth:sign_up_google_start" : "auth:sign_in_google_start",+ { redirect_to: redirectTo },+ );+ const result = await authClient.signIn.social({+ provider: "google",+ callbackURL: toAuthCallbackURL(redirectTo),+ ...(isSignUp+ ? {+ newUserCallbackURL: toAuthCallbackURL(postSignupRedirect),+ requestSignUp: true,+ }+ : {}),+ });+ if (!result.error) return;+ setError(result.error.message || fallbackMessage);+ } catch {+ setError(fallbackMessage);+ }+ setIsStarting(false);+ }++ const fallbackMessage = isSignUp+ ? "Google sign up is not available right now."+ : "Google sign in is not available right now.";++ return { isStarting, error, start, clearError: () => setError(null) };+}diff --git a/src/routes/_auth.sign-in.tsx b/src/routes/_auth.sign-in.tsxindex b8a40478..8648ec44 100644--- a/src/routes/_auth.sign-in.tsx+++ b/src/routes/_auth.sign-in.tsx@@ -1,13 +1,16 @@-import { useForm } from "@tanstack/react-form";import { Link, createFileRoute, useNavigate } from "@tanstack/react-router";import { useState } from "react";+import { useAppForm } from "@/client/components/form/useAppForm";+import { Alert, AlertDescription } from "@/client/components/ui/alert";+import { Button } from "@/client/components/ui/button";import {AuthPageCard,AuthMethodChooser,authRedirectSearchSchema,useAuthPageState,} from "@/client/features/auth/AuthPage";-import { getFieldError, getFormError } from "@/client/lib/forms";+import { useGoogleAuth } from "@/client/features/auth/useGoogleAuth";+import { getFormError } from "@/client/lib/forms";import { captureClientEvent } from "@/client/lib/posthog";import { authClient } from "@/lib/auth-client";import {@@ -34,10 +37,9 @@ function SignInPage() {search.redirect,);const [showEmailForm, setShowEmailForm] = useState(false);- const [isStartingGoogle, setIsStartingGoogle] = useState(false);- const [socialError, setSocialError] = useState<string | null>(null);+ const google = useGoogleAuth({ redirectTo });- const form = useForm({+ const form = useAppForm({defaultValues: {email: "",password: "",@@ -97,31 +99,6 @@ function SignInPage() {},});- async function handleContinueWithGoogle() {- setSocialError(null);- setIsStartingGoogle(true);-- try {- captureClientEvent("auth:sign_in_google_start", {- redirect_to: redirectTo,- });- const result = await authClient.signIn.social({- provider: "google",- callbackURL: toAuthCallbackURL(redirectTo),- });-- if (result.error) {- setSocialError(- result.error.message || "Google sign in is not available right now.",- );- setIsStartingGoogle(false);- }- } catch {- setSocialError("Google sign in is not available right now.");- setIsStartingGoogle(false);- }- }-return (<AuthPageCardtitle="Sign in"@@ -130,15 +107,15 @@ function SignInPage() {<divclassName={showEmailForm- ? "flex justify-between text-sm text-base-content/50"- : "text-sm text-base-content/50"+ ? "flex w-full justify-between text-sm text-muted-foreground"+ : "w-full text-sm text-muted-foreground"}>{showEmailForm ? (<Linkto="/forgot-password"search={getSignInSearch(redirectTo)}- className="text-base-content underline underline-offset-2 hover:text-base-content/80 transition-colors"+ className="text-foreground underline underline-offset-2 hover:text-foreground/80 transition-colors">Forgot password?</Link>@@ -146,7 +123,7 @@ function SignInPage() {<Linkto="/sign-up"search={getSignInSearch(redirectTo)}- className="text-base-content underline underline-offset-2 hover:text-base-content/80 transition-colors"+ className="text-foreground underline underline-offset-2 hover:text-foreground/80 transition-colors">Create account</Link>@@ -159,97 +136,76 @@ function SignInPage() {<AuthMethodChoosergoogleLabel="Continue with Google"disabled={!isHostedMode}- isBusy={isStartingGoogle}+ isBusy={google.isStarting}onContinueWithGoogle={() => {- void handleContinueWithGoogle();+ void google.start();}}onContinueWithEmail={() => {setShowEmailForm(true);- setSocialError(null);+ google.clearError();}}/>- {socialError ? (- <p className="text-sm text-error">{socialError}</p>+ {google.error ? (+ <Alert variant="destructive">+ <AlertDescription>{google.error}</AlertDescription>+ </Alert>) : null}</>) : (- <form- className="space-y-4"- onSubmit={(event) => {- event.preventDefault();- void form.handleSubmit();- }}- >- <form.Field name="email">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="email"- className="input input-bordered w-full"- placeholder="Email address..."- value={field.state.value}- onChange={(event) => field.handleChange(event.target.value)}- autoComplete="email"- required- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- <form.Field name="password">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="password"- className="input input-bordered w-full"- placeholder="Password..."- value={field.state.value}- onChange={(event) => field.handleChange(event.target.value)}- autoComplete="current-password"- required- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- <form.Subscribe- selector={(state) => ({- submitError: state.errorMap.onSubmit,- isSubmitting: state.isSubmitting,- })}- >- {({ submitError, isSubmitting }) => {- const errorMessage = getFormError(submitError);- return (- <>- {errorMessage ? (- <p className="text-sm text-error">{errorMessage}</p>- ) : null}- <button- className="btn btn-soft w-full"- disabled={isSubmitting}- >- {isSubmitting ? "Signing in..." : "Sign in"}- </button>- </>- );- }}- </form.Subscribe>- </form>+ <form.AppForm>+ <form.Form className="space-y-4">+ <form.AppField name="email">+ {(field) => (+ <field.TextField+ label="Email address"+ type="email"+ placeholder="Email address..."+ autoComplete="email"+ required+ />+ )}+ </form.AppField>+ <form.AppField name="password">+ {(field) => (+ <field.TextField+ label="Password"+ type="password"+ placeholder="Password..."+ autoComplete="current-password"+ required+ />+ )}+ </form.AppField>++ <form.Subscribe+ selector={(state) => ({+ submitError: state.errorMap.onSubmit,+ isSubmitting: state.isSubmitting,+ })}+ >+ {({ submitError, isSubmitting }) => {+ const errorMessage = getFormError(submitError);+ return (+ <>+ {errorMessage ? (+ <Alert variant="destructive">+ <AlertDescription>{errorMessage}</AlertDescription>+ </Alert>+ ) : null}+ <Button+ type="submit"+ variant="secondary"+ className="w-full"+ pending={isSubmitting}+ >+ {isSubmitting ? "Signing in..." : "Sign in"}+ </Button>+ </>+ );+ }}+ </form.Subscribe>+ </form.Form>+ </form.AppForm>)}</AuthPageCard>);diff --git a/src/routes/_auth.sign-up.tsx b/src/routes/_auth.sign-up.tsxindex e5a8998d..1f24025c 100644--- a/src/routes/_auth.sign-up.tsx+++ b/src/routes/_auth.sign-up.tsx@@ -1,6 +1,8 @@-import { useForm } from "@tanstack/react-form";import { Link, createFileRoute, useNavigate } from "@tanstack/react-router";import { useState } from "react";+import { useAppForm } from "@/client/components/form/useAppForm";+import { Alert, AlertDescription } from "@/client/components/ui/alert";+import { Button } from "@/client/components/ui/button";import {AuthPageCard,AuthMethodChooser,@@ -12,34 +14,19 @@ import {TurnstileWidget,useTurnstileCaptcha,} from "@/client/features/auth/TurnstileWidget";-import { getFieldError, getFormError } from "@/client/lib/forms";+import { passwordSchema } from "@/client/features/auth/passwordSchema";+import { useGoogleAuth } from "@/client/features/auth/useGoogleAuth";+import { getFormError } from "@/client/lib/forms";import { captureClientEvent } from "@/client/lib/posthog";import { authClient } from "@/lib/auth-client";-import {- getSignInSearch,- getVerifyEmailSearch,- toAuthCallbackURL,-} from "@/lib/auth-redirect";-import {- HOSTED_PASSWORD_MAX_LENGTH,- HOSTED_PASSWORD_MIN_LENGTH,-} from "@/lib/auth-options";+import { getSignInSearch, getVerifyEmailSearch } from "@/lib/auth-redirect";import { z } from "zod";const signUpSchema = z.object({name: z.string().trim(),email: z.string().trim().email("Enter a valid email address."),- password: z- .string()- .min(- HOSTED_PASSWORD_MIN_LENGTH,- `Password must be at least ${HOSTED_PASSWORD_MIN_LENGTH} characters.`,- )- .max(- HOSTED_PASSWORD_MAX_LENGTH,- `Password must be at most ${HOSTED_PASSWORD_MAX_LENGTH} characters.`,- ),+ password: passwordSchema,confirmPassword: z.string(),}).refine((value) => value.password === value.confirmPassword, {@@ -58,13 +45,13 @@ function SignUpPage() {const { redirectTo, isHostedMode } = useAuthPageState(search.redirect);const postSignupRedirect = redirectTo === "/" ? "/onboarding" : redirectTo;const [showEmailForm, setShowEmailForm] = useState(false);- const google = useGoogleSignUp({ redirectTo, postSignupRedirect });+ const google = useGoogleAuth({ redirectTo, postSignupRedirect });// Turnstile is active only in hosted mode with a configured site key.const isTurnstileEnabled = isHostedMode && Boolean(TURNSTILE_SITE_KEY);const captcha = useTurnstileCaptcha();- const form = useForm({+ const form = useAppForm({defaultValues: {name: "",email: "",@@ -149,25 +136,25 @@ function SignUpPage() {footer={isHostedMode ? (showEmailForm ? (- <button+ <Buttontype="button"- className="text-sm text-base-content underline underline-offset-2 hover:text-base-content/80 transition-colors"+ variant="link"onClick={() => {setShowEmailForm(false);google.clearError();}}>Back to signup- </button>+ </Button>) : (<div className="space-y-4">- <p className="text-sm leading-relaxed text-base-content/60">+ <p className="text-sm leading-relaxed text-muted-foreground">By signing up, you agree to our{" "}<ahref="https://openseo.so/terms-and-conditions"target="_blank"rel="noreferrer"- className="text-base-content underline underline-offset-2 hover:text-base-content/80 transition-colors"+ className="text-foreground underline underline-offset-2 hover:text-foreground/80 transition-colors">Terms</a>{" "}@@ -176,19 +163,19 @@ function SignUpPage() {href="https://openseo.so/privacy"target="_blank"rel="noreferrer"- className="text-base-content underline underline-offset-2 hover:text-base-content/80 transition-colors"+ className="text-foreground underline underline-offset-2 hover:text-foreground/80 transition-colors">Privacy Policy</a>.</p>- <p className="text-sm text-base-content/50">+ <p className="text-sm text-muted-foreground">Already have an account?{" "}<Linkto="/sign-in"search={getSignInSearch(redirectTo)}- className="text-base-content underline underline-offset-2 hover:text-base-content/80 transition-colors"+ className="text-foreground underline underline-offset-2 hover:text-foreground/80 transition-colors">Sign in</Link>@@ -213,192 +200,95 @@ function SignUpPage() {}}/>{google.error ? (- <p className="text-sm text-error">{google.error}</p>+ <Alert variant="destructive">+ <AlertDescription>{google.error}</AlertDescription>+ </Alert>) : null}</>) : (- <form- className="space-y-4"- onSubmit={(event) => {- event.preventDefault();- void form.handleSubmit();- }}- >- <form.Field name="name">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="text"- className="input input-bordered w-full"- placeholder="Name (optional)..."- value={field.state.value}- onChange={(event) => field.handleChange(event.target.value)}- autoComplete="name"- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- <form.Field name="email">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="email"- className="input input-bordered w-full"- placeholder="Email address..."- value={field.state.value}- onChange={(event) => field.handleChange(event.target.value)}- autoComplete="email"- required- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>+ <form.AppForm>+ <form.Form className="space-y-4">+ <form.AppField name="name">+ {(field) => (+ <field.TextField+ label="Name (optional)"+ placeholder="Name (optional)..."+ autoComplete="name"+ />+ )}+ </form.AppField>+ <form.AppField name="email">+ {(field) => (+ <field.TextField+ label="Email address"+ type="email"+ placeholder="Email address..."+ autoComplete="email"+ required+ />+ )}+ </form.AppField>+ <form.AppField name="password">+ {(field) => (+ <field.TextField+ label="Password"+ type="password"+ placeholder="Password..."+ autoComplete="new-password"+ required+ />+ )}+ </form.AppField>+ <form.AppField name="confirmPassword">+ {(field) => (+ <field.TextField+ label="Confirm password"+ type="password"+ placeholder="Confirm password..."+ autoComplete="new-password"+ required+ />+ )}+ </form.AppField>- <form.Field name="password">- {(field) => {- const error = getFieldError(field.state.meta.errors);+ {isTurnstileEnabled ? (+ <TurnstileWidget+ onToken={captcha.onToken}+ resetNonce={captcha.resetNonce}+ />+ ) : null}- return (- <div>- <input- type="password"- className="input input-bordered w-full"- placeholder="Password..."- value={field.state.value}- onChange={(event) => field.handleChange(event.target.value)}- autoComplete="new-password"- required- minLength={HOSTED_PASSWORD_MIN_LENGTH}- maxLength={HOSTED_PASSWORD_MAX_LENGTH}- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- <form.Field name="confirmPassword">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="password"- className="input input-bordered w-full"- placeholder="Confirm password..."- value={field.state.value}- onChange={(event) => field.handleChange(event.target.value)}- autoComplete="new-password"- required- minLength={HOSTED_PASSWORD_MIN_LENGTH}- maxLength={HOSTED_PASSWORD_MAX_LENGTH}- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- {isTurnstileEnabled ? (- <TurnstileWidget- onToken={captcha.onToken}- resetNonce={captcha.resetNonce}- />- ) : null}-- <form.Subscribe- selector={(state) => ({- submitError: state.errorMap.onSubmit,- isSubmitting: state.isSubmitting,- })}- >- {({ submitError, isSubmitting }) => {- const errorMessage = getFormError(submitError);- return (- <>- {errorMessage ? (- <p className="text-sm text-error">{errorMessage}</p>- ) : null}- <button- className="btn btn-soft w-full"- disabled={- isSubmitting || (isTurnstileEnabled && !captcha.hasToken)- }- >- {isSubmitting ? "Creating account..." : "Create account"}- </button>- </>- );- }}- </form.Subscribe>- </form>+ <form.Subscribe+ selector={(state) => ({+ submitError: state.errorMap.onSubmit,+ isSubmitting: state.isSubmitting,+ })}+ >+ {({ submitError, isSubmitting }) => {+ const errorMessage = getFormError(submitError);+ return (+ <>+ {errorMessage ? (+ <Alert variant="destructive">+ <AlertDescription>{errorMessage}</AlertDescription>+ </Alert>+ ) : null}+ <Button+ type="submit"+ variant="secondary"+ className="w-full"+ pending={isSubmitting}+ disabled={isTurnstileEnabled && !captcha.hasToken}+ >+ {isSubmitting ? "Creating account..." : "Create account"}+ </Button>+ </>+ );+ }}+ </form.Subscribe>+ </form.Form>+ </form.AppForm>)}</AuthPageCard>);}--// Google sign-up: kicks off the social OAuth redirect and surfaces its error.-function useGoogleSignUp({- redirectTo,- postSignupRedirect,-}: {- redirectTo: string;- postSignupRedirect: string;-}) {- const [isStarting, setIsStarting] = useState(false);- const [error, setError] = useState<string | null>(null);-- const start = async () => {- setError(null);- setIsStarting(true);-- try {- captureClientEvent("auth:sign_up_google_start", {- redirect_to: redirectTo,- });- const result = await authClient.signIn.social({- provider: "google",- callbackURL: toAuthCallbackURL(redirectTo),- newUserCallbackURL: toAuthCallbackURL(postSignupRedirect),- requestSignUp: true,- });-- if (result.error) {- setError(- result.error.message || "Google sign up is not available right now.",- );- setIsStarting(false);- }- } catch {- setError("Google sign up is not available right now.");- setIsStarting(false);- }- };-- return {- isStarting,- error,- start,- clearError: () => setError(null),- };-}diff --git a/src/routes/_auth.tsx b/src/routes/_auth.tsxindex 4d84796a..f9551f1f 100644--- a/src/routes/_auth.tsx+++ b/src/routes/_auth.tsx@@ -1,5 +1,5 @@import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";-import { useEffect } from "react";+import { useEffect, useState } from "react";import {AuthPageShell,authRedirectSearchSchema,@@ -18,9 +18,14 @@ function AuthPageLayout() {const search = Route.useSearch();const navigate = useNavigate();const { data: session, isPending } = useSession();+ const [hasResolvedSession, setHasResolvedSession] = useState(false);const isHostedMode = isHostedClientAuthMode();const redirectTo = getCurrentAuthRedirect(search.redirect);+ useEffect(() => {+ if (!isPending) setHasResolvedSession(true);+ }, [isPending]);+useEffect(() => {if (!session?.user?.id) {return;@@ -40,7 +45,10 @@ function AuthPageLayout() {}, [navigate, redirectTo, session?.user?.id]);// Loading the session, or handing a signed-in user off to the destination.- if (isHostedMode && (isPending || session?.user?.id)) {+ if (+ isHostedMode &&+ ((isPending && !hasResolvedSession) || session?.user?.id)+ ) {return <PageLoading fullScreen />;}diff --git a/src/routes/_authenticated.oauth-consent.tsx b/src/routes/_authenticated.oauth-consent.tsxindex 44af336b..3b8fb640 100644--- a/src/routes/_authenticated.oauth-consent.tsx+++ b/src/routes/_authenticated.oauth-consent.tsx@@ -3,6 +3,14 @@ import { Check, Database, KeyRound, User } from "lucide-react";import { useEffect, useState } from "react";import { useSession } from "@/lib/auth-client";import { captureClientEvent } from "@/client/lib/posthog";+import { Alert, AlertDescription } from "@/client/components/ui/alert";+import { Button } from "@/client/components/ui/button";+import {+ Card,+ CardContent,+ CardHeader,+ CardTitle,+} from "@/client/components/ui/card";export const Route = createFileRoute("/_authenticated/oauth-consent")({component: OAuthConsentPage,@@ -70,77 +78,83 @@ function OAuthConsentPage() {}return (- <div className="w-full max-w-md rounded-2xl border border-base-300 bg-base-100 p-8 shadow-sm">- <div className="flex flex-col items-center text-center">+ <Card className="w-full max-w-md">+ <CardHeader className="flex flex-col items-center text-center"><imgsrc="/transparent-logo.png"alt="OpenSEO"className="size-10 rounded-lg"/>- <h1 className="mt-5 text-xl font-semibold">Authorize MCP access</h1>- <p className="mt-2 text-sm text-base-content/70">+ <CardTitle className="mt-5 text-xl">+ <h1>Authorize MCP access</h1>+ </CardTitle>+ <p className="mt-2 text-sm text-muted-foreground">An MCP client is requesting access to your OpenSEO workspace.</p>- </div>-- {/* _authenticated only renders this page with a signed-in user. */}- <div className="mt-6 flex items-center gap-3 rounded-lg border border-base-300 bg-base-200/50 px-3 py-2 text-sm">- <div className="flex size-7 items-center justify-center rounded-full bg-base-300">- <User className="size-4" />- </div>- <div className="flex-1">- <div className="text-xs text-base-content/60">Signed in as</div>- <div className="font-medium">{session?.user.email}</div>+ </CardHeader>+ <CardContent>+ {/* _authenticated only renders this page with a signed-in user. */}+ <div className="mt-6 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-3 py-2 text-sm">+ <div className="flex size-7 items-center justify-center rounded-full bg-muted">+ <User className="size-4" />+ </div>+ <div className="flex-1">+ <div className="text-xs text-muted-foreground">Signed in as</div>+ <div className="font-medium">{session?.user.email}</div>+ </div></div>- </div>- <div className="mt-6">- <div className="text-xs font-medium uppercase tracking-wide text-base-content/60">- This will allow it to- </div>- <ul className="mt-3 space-y-3">- {SCOPES.map((scope) => (- <li key={scope.label} className="flex gap-3">- <Check className="mt-0.5 size-4 shrink-0 text-primary" />- <div>- <div className="text-sm font-medium">{scope.label}</div>- <div className="text-xs text-base-content/60">- {scope.description}+ <div className="mt-6">+ <div className="text-xs font-medium uppercase tracking-wide text-muted-foreground">+ This will allow it to+ </div>+ <ul className="mt-3 space-y-3">+ {SCOPES.map((scope) => (+ <li key={scope.label} className="flex gap-3">+ <Check className="mt-0.5 size-4 shrink-0 text-primary" />+ <div>+ <div className="text-sm font-medium">{scope.label}</div>+ <div className="text-xs text-muted-foreground">+ {scope.description}+ </div></div>- </div>- </li>- ))}- </ul>- </div>-- {error ? (- <div className="mt-6 rounded-lg border border-error/30 bg-error/10 px-3 py-2 text-sm text-error">- {error}+ </li>+ ))}+ </ul></div>- ) : null}- <div className="mt-8 flex gap-2">- <button- type="button"- className="btn btn-ghost flex-1"- disabled={pendingAction !== null}- onClick={() => void respond(false)}- >- {pendingAction === "cancel" ? "Canceling..." : "Cancel"}- </button>- <button- type="button"- className="btn btn-primary flex-1"- disabled={pendingAction !== null}- onClick={() => void respond(true)}- >- {pendingAction === "authorize" ? "Authorizing..." : "Authorize"}- </button>- </div>+ {error ? (+ <Alert variant="destructive" className="mt-6">+ <AlertDescription>{error}</AlertDescription>+ </Alert>+ ) : null}- <p className="mt-6 text-center text-xs text-base-content/50">- You can revoke access at any time in Settings.- </p>- </div>+ <div className="mt-8 flex gap-2">+ <Button+ type="button"+ variant="ghost"+ className="flex-1"+ pending={pendingAction === "cancel"}+ disabled={pendingAction !== null}+ onClick={() => void respond(false)}+ >+ {pendingAction === "cancel" ? "Canceling..." : "Cancel"}+ </Button>+ <Button+ type="button"+ className="flex-1"+ pending={pendingAction === "authorize"}+ disabled={pendingAction !== null}+ onClick={() => void respond(true)}+ >+ {pendingAction === "authorize" ? "Authorizing..." : "Authorize"}+ </Button>+ </div>++ <p className="mt-6 text-center text-xs text-muted-foreground">+ You can revoke access at any time in Settings.+ </p>+ </CardContent>+ </Card>);}diff --git a/src/routes/_authenticated.tsx b/src/routes/_authenticated.tsxindex 87e86959..319993c6 100644--- a/src/routes/_authenticated.tsx+++ b/src/routes/_authenticated.tsx@@ -2,6 +2,7 @@ import { Link, Outlet, createFileRoute } from "@tanstack/react-router";import { AuthPageCard, AuthPageShell } from "@/client/features/auth/AuthPage";import { useHostedAuthRouteGuard } from "@/client/features/auth/useHostedAuthRouteGuard";import { PageLoading } from "@/client/components/Spinner";+import { Button } from "@/client/components/ui/button";export const Route = createFileRoute("/_authenticated")({component: AuthenticatedShellLayout,@@ -18,9 +19,14 @@ function AuthenticatedShellLayout() {title="Not available"helperText="This page isn't available right now.">- <Link to="/" className="btn btn-soft w-full">+ <Button+ nativeButton={false}+ render={<Link to="/" />}+ variant="secondary"+ className="w-full"+ >Back to OpenSEO- </Link>+ </Button></AuthPageCard></AuthPageShell>);diff --git a/src/routes/accept-invitation.$id.tsx b/src/routes/accept-invitation.$id.tsxindex 454a35cd..1fbca611 100644--- a/src/routes/accept-invitation.$id.tsx+++ b/src/routes/accept-invitation.$id.tsx@@ -1,5 +1,7 @@import { useQuery } from "@tanstack/react-query";import { Spinner } from "@/client/components/Spinner";+import { Alert, AlertDescription } from "@/client/components/ui/alert";+import { Button } from "@/client/components/ui/button";import { Link, createFileRoute, notFound } from "@tanstack/react-router";import { useState } from "react";import { AuthPageCard, AuthPageShell } from "@/client/features/auth/AuthPage";@@ -41,25 +43,27 @@ function SignedOutInvitationCard({ invitationId }: { invitationId: string }) {return (<AuthPageCard title="You’re invited">- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground">You’ve been invited to join an organization on OpenSEO. Sign inwith the email address that received the invitation to accept it.</p><div className="space-y-2">- <Link- to="/sign-up"- search={{ redirect }}- className="btn btn-soft w-full"+ <Button+ nativeButton={false}+ render={<Link to="/sign-up" search={{ redirect }} />}+ variant="secondary"+ className="w-full">Create account- </Link>- <Link- to="/sign-in"- search={{ redirect }}- className="btn btn-ghost w-full"+ </Button>+ <Button+ nativeButton={false}+ render={<Link to="/sign-in" search={{ redirect }} />}+ variant="ghost"+ className="w-full">Sign in- </Link>+ </Button></div></AuthPageCard>);@@ -158,7 +162,7 @@ function InvitationCard({if (invitationQuery.isError) {return (<AuthPageCard title="Invitation unavailable">- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground">This invitation may have expired, been canceled, or belong to adifferent email address. You’re signed in as{" "}<span className="font-medium" data-ph-mask>@@ -166,14 +170,15 @@ function InvitationCard({</span>.</p>- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground">If the invitation was sent to another address, sign out and sign backin with that email. Otherwise ask your teammate to send a new invite.</p><div className="space-y-2">- <button+ <Buttontype="button"- className="btn btn-soft w-full"+ variant="secondary"+ className="w-full"onClick={() => {// Signs out, then lands on sign-in with a redirect back to this// invitation (staying signed in would bounce straight back here).@@ -181,10 +186,15 @@ function InvitationCard({}}>Use a different account- </button>- <Link to="/" className="btn btn-ghost w-full">+ </Button>+ <Button+ nativeButton={false}+ render={<Link to="/" />}+ variant="ghost"+ className="w-full"+ >Go to dashboard- </Link>+ </Button></div></AuthPageCard>);@@ -193,23 +203,28 @@ function InvitationCard({if (declined) {return (<AuthPageCard title="Invitation declined">- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground">You declined the invitation to join{" "}<span className="font-medium">{invitationQuery.data.organizationName}</span>.</p>- <Link to="/" className="btn btn-ghost w-full">+ <Button+ nativeButton={false}+ render={<Link to="/" />}+ variant="ghost"+ className="w-full"+ >Go to dashboard- </Link>+ </Button></AuthPageCard>);}return (<AuthPageCard title="Join organization">- <p className="text-sm text-base-content/70">+ <p className="text-sm text-muted-foreground"><span className="font-medium" data-ph-mask>{invitationQuery.data.inviterEmail}</span>{" "}@@ -219,24 +234,32 @@ function InvitationCard({</span>{" "}on OpenSEO.</p>- {actionError ? <p className="text-sm text-error">{actionError}</p> : null}+ {actionError ? (+ <Alert variant="destructive">+ <AlertDescription>{actionError}</AlertDescription>+ </Alert>+ ) : null}<div className="space-y-2">- <button+ <Buttontype="button"- className="btn btn-soft w-full"+ variant="secondary"+ className="w-full"+ pending={pendingAction === "accept"}disabled={pendingAction !== null}onClick={() => void handleAccept()}>{pendingAction === "accept" ? "Joining..." : "Accept invitation"}- </button>- <button+ </Button>+ <Buttontype="button"- className="btn btn-ghost w-full"+ variant="ghost"+ className="w-full"+ pending={pendingAction === "decline"}disabled={pendingAction !== null}onClick={() => void handleDecline()}>{pendingAction === "decline" ? "Declining..." : "Decline"}- </button>+ </Button></div></AuthPageCard>);diff --git a/src/routes/auth-error.tsx b/src/routes/auth-error.tsxindex 37cddb77..eba6b65b 100644--- a/src/routes/auth-error.tsx+++ b/src/routes/auth-error.tsx@@ -1,5 +1,6 @@import { Link, createFileRoute } from "@tanstack/react-router";import { z } from "zod";+import { Button } from "@/client/components/ui/button";import { AuthPageCard, AuthPageShell } from "@/client/features/auth/AuthPage";import { googleAuthErrorCopy } from "@/client/features/integrations/googleAuthErrorCopy";@@ -30,15 +31,20 @@ function AuthErrorPage() {helperText={copy.description}footer={error ? (- <p className="font-mono text-xs text-base-content/40">+ <p className="font-mono text-xs text-muted-foreground">Code: {error}</p>) : undefined}>- <Link to="/" className="btn btn-soft w-full">+ <Button+ nativeButton={false}+ render={<Link to="/" />}+ variant="secondary"+ className="w-full"+ >Back to OpenSEO- </Link>+ </Button></AuthPageCard></AuthPageShell>);diff --git a/src/routes/forgot-password.tsx b/src/routes/forgot-password.tsxindex e16e351f..fb6ec5c2 100644--- a/src/routes/forgot-password.tsx+++ b/src/routes/forgot-password.tsx@@ -1,11 +1,13 @@-import { useForm } from "@tanstack/react-form";import { Link, createFileRoute } from "@tanstack/react-router";+import { useAppForm } from "@/client/components/form/useAppForm";+import { Alert, AlertDescription } from "@/client/components/ui/alert";+import { Button } from "@/client/components/ui/button";import {AuthPageCard,AuthPageShell,authRedirectSearchSchema,} from "@/client/features/auth/AuthPage";-import { getFieldError, getFormError } from "@/client/lib/forms";+import { getFormError } from "@/client/lib/forms";import { authClient } from "@/lib/auth-client";import { isHostedClientAuthMode } from "@/lib/auth-mode";import { getSignInSearch, normalizeAuthRedirect } from "@/lib/auth-redirect";@@ -25,7 +27,7 @@ function ForgotPasswordPage() {const redirectTo = normalizeAuthRedirect(search.redirect);const isHostedMode = isHostedClientAuthMode();- const form = useForm({+ const form = useAppForm({defaultValues: {email: "",},@@ -80,7 +82,7 @@ function ForgotPasswordPage() {title={isSuccess ? "Check your email" : "Forgot password"}helperText={isSuccess- ? `If an account exists for ${submittedEmail}, we sent a reset link.`+ ? undefined: isHostedMode? "Enter your email and we'll send you a password reset link.": "Password reset isn't available right now."@@ -90,7 +92,7 @@ function ForgotPasswordPage() {<Linkto="/sign-in"search={getSignInSearch(redirectTo)}- className="text-base-content/50 hover:text-base-content transition-colors"+ className="text-muted-foreground hover:text-foreground transition-colors">Back to sign in</Link>@@ -98,56 +100,46 @@ function ForgotPasswordPage() {}>{isSuccess ? (- <div className="alert alert-success">- <span>- If an account exists for that email, you'll receive password- reset instructions shortly.- </span>- </div>+ <Alert variant="success">+ <AlertDescription>+ If an account exists for {submittedEmail}, you'll receive+ password reset instructions shortly.+ </AlertDescription>+ </Alert>) : (- <form- className="space-y-4"- onSubmit={(event) => {- event.preventDefault();- void form.handleSubmit();- }}- >- <form.Field name="email">- {(field) => {- const error = getFieldError(field.state.meta.errors);+ <form.AppForm>+ <form.Form className="space-y-4">+ <form.AppField name="email">+ {(field) => (+ <field.TextField+ label="Email address"+ type="email"+ placeholder="Email address..."+ autoComplete="email"+ disabled={!isHostedMode}+ required+ />+ )}+ </form.AppField>- return (- <div>- <input- type="email"- className="input input-bordered w-full"- placeholder="Email address..."- value={field.state.value}- onChange={(event) =>- field.handleChange(event.target.value)- }- autoComplete="email"- disabled={!isHostedMode}- required- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- {errorMessage ? (- <p className="text-sm text-error">{errorMessage}</p>- ) : null}- <button- className="btn btn-soft w-full"- disabled={!isHostedMode || isSubmitting}- >- {isSubmitting ? "Sending reset link..." : "Send reset link"}- </button>- </form>+ {errorMessage ? (+ <Alert variant="destructive">+ <AlertDescription>{errorMessage}</AlertDescription>+ </Alert>+ ) : null}+ <Button+ type="submit"+ variant="secondary"+ className="w-full"+ pending={isSubmitting}+ disabled={!isHostedMode}+ >+ {isSubmitting+ ? "Sending reset link..."+ : "Send reset link"}+ </Button>+ </form.Form>+ </form.AppForm>)}</AuthPageCard>);diff --git a/src/routes/reset-password.tsx b/src/routes/reset-password.tsxindex 2432ad47..221f40d8 100644--- a/src/routes/reset-password.tsx+++ b/src/routes/reset-password.tsx@@ -1,32 +1,22 @@-import { useForm } from "@tanstack/react-form";import { Link, createFileRoute } from "@tanstack/react-router";+import { useAppForm } from "@/client/components/form/useAppForm";+import { Alert, AlertDescription } from "@/client/components/ui/alert";+import { Button } from "@/client/components/ui/button";import {AuthPageCard,AuthPageShell,authRedirectSearchSchema,} from "@/client/features/auth/AuthPage";-import { getFieldError, getFormError } from "@/client/lib/forms";+import { passwordSchema } from "@/client/features/auth/passwordSchema";+import { getFormError } from "@/client/lib/forms";import { authClient } from "@/lib/auth-client";import { isHostedClientAuthMode } from "@/lib/auth-mode";import { getSignInSearch, normalizeAuthRedirect } from "@/lib/auth-redirect";-import {- HOSTED_PASSWORD_MAX_LENGTH,- HOSTED_PASSWORD_MIN_LENGTH,-} from "@/lib/auth-options";import { z } from "zod";const resetPasswordSchema = z.object({- password: z- .string()- .min(- HOSTED_PASSWORD_MIN_LENGTH,- `Password must be at least ${HOSTED_PASSWORD_MIN_LENGTH} characters.`,- )- .max(- HOSTED_PASSWORD_MAX_LENGTH,- `Password must be at most ${HOSTED_PASSWORD_MAX_LENGTH} characters.`,- ),+ password: passwordSchema,confirmPassword: z.string(),}).refine((value) => value.password === value.confirmPassword, {@@ -104,7 +94,7 @@ function ResetPasswordPage() {const isHostedMode = isHostedClientAuthMode();const routeError = getResetPasswordErrorMessage(search.error);const token = search.token;- const form = useForm({+ const form = useAppForm({defaultValues: {password: "",confirmPassword: "",@@ -166,108 +156,87 @@ function ResetPasswordPage() {title={pageCopy.title}helperText={pageCopy.helperText}footer={- <p className="text-sm">- <Link- to="/sign-in"- search={getSignInSearch(redirectTo)}- className="text-base-content/50 hover:text-base-content transition-colors"- >- Sign in- </Link>- </p>+ isComplete ? undefined : (+ <p className="text-sm">+ <Link+ to="/sign-in"+ search={getSignInSearch(redirectTo)}+ className="text-muted-foreground hover:text-foreground transition-colors"+ >+ Sign in+ </Link>+ </p>+ )}>{!isHostedMode ? null : isComplete ? (- <a- href={- redirectTo === "/"- ? "/sign-in"- : `/sign-in?redirect=${encodeURIComponent(redirectTo)}`+ <Button+ nativeButton={false}+ variant="secondary"+ className="w-full"+ render={+ <Link to="/sign-in" search={getSignInSearch(redirectTo)} />}- className="btn btn-soft w-full">Continue to sign in- </a>+ </Button>) : routeError || !token ? (- <Link- to="/forgot-password"- search={getSignInSearch(redirectTo)}- className="btn btn-soft w-full"+ <Button+ nativeButton={false}+ variant="secondary"+ className="w-full"+ render={+ <Link+ to="/forgot-password"+ search={getSignInSearch(redirectTo)}+ />+ }>Request a new reset link- </Link>+ </Button>) : (- <form- className="space-y-4"- onSubmit={(event) => {- event.preventDefault();- void form.handleSubmit();- }}- >- <form.Field name="password">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="password"- className="input input-bordered w-full"- placeholder="New password..."- value={field.state.value}- onChange={(event) =>- field.handleChange(event.target.value)- }- autoComplete="new-password"- minLength={HOSTED_PASSWORD_MIN_LENGTH}- maxLength={HOSTED_PASSWORD_MAX_LENGTH}- required- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- <form.Field name="confirmPassword">- {(field) => {- const error = getFieldError(field.state.meta.errors);-- return (- <div>- <input- type="password"- className="input input-bordered w-full"- placeholder="Confirm new password..."- value={field.state.value}- onChange={(event) =>- field.handleChange(event.target.value)- }- autoComplete="new-password"- minLength={HOSTED_PASSWORD_MIN_LENGTH}- maxLength={HOSTED_PASSWORD_MAX_LENGTH}- required- />- {error ? (- <p className="mt-1 text-sm text-error">{error}</p>- ) : null}- </div>- );- }}- </form.Field>-- {errorMessage ? (- <p className="text-sm text-error">{errorMessage}</p>- ) : null}- <button- className="btn btn-soft w-full"- disabled={isSubmitting}- >- {isSubmitting ? "Updating password..." : "Update password"}- </button>- </form>+ <form.AppForm>+ <form.Form className="space-y-4">+ <form.AppField name="password">+ {(field) => (+ <field.TextField+ label="New password"+ type="password"+ placeholder="New password..."+ autoComplete="new-password"+ required+ />+ )}+ </form.AppField>+ <form.AppField name="confirmPassword">+ {(field) => (+ <field.TextField+ label="Confirm new password"+ type="password"+ placeholder="Confirm new password..."+ autoComplete="new-password"+ required+ />+ )}+ </form.AppField>++ {errorMessage ? (+ <Alert variant="destructive">+ <AlertDescription>{errorMessage}</AlertDescription>+ </Alert>+ ) : null}+ <Button+ type="submit"+ variant="secondary"+ className="w-full"+ pending={isSubmitting}+ >+ {isSubmitting+ ? "Updating password..."+ : "Update password"}+ </Button>+ </form.Form>+ </form.AppForm>)}</AuthPageCard>);diff --git a/src/routes/verify-email.tsx b/src/routes/verify-email.tsxindex 28769b7e..22848e65 100644--- a/src/routes/verify-email.tsx+++ b/src/routes/verify-email.tsx@@ -1,6 +1,8 @@import { Link, createFileRoute } from "@tanstack/react-router";import { useEffect, useState } from "react";import { toast } from "sonner";+import { Button } from "@/client/components/ui/button";+import { Spinner } from "@/client/components/ui/spinner";import {AuthPageCard,AuthPageShell,@@ -67,7 +69,7 @@ function getVerifyEmailPageCopy({if (errorMessage) {return {title: "We couldn't confirm your email",- helperText: errorMessage,+ helperText: undefined,};}@@ -196,7 +198,7 @@ function VerifyEmailPage() {<Linkto="/sign-in"search={getSignInSearch(redirectTo)}- className="text-base-content/50 hover:text-base-content transition-colors"+ className="text-muted-foreground hover:text-foreground transition-colors">Back to sign in</Link>@@ -204,31 +206,21 @@ function VerifyEmailPage() {}>{!isHostedMode ? null : errorMessage ? (- <div className="space-y-3">- <div className="alert alert-error">- <span>{errorMessage}</span>- </div>- <Link- to="/sign-in"- search={getSignInSearch(redirectTo)}- className="btn btn-soft w-full"- >- Back to sign in- </Link>- </div>+ <p className="text-sm text-destructive">{errorMessage}</p>) : isPending || isRedirecting ? (<div className="flex justify-center py-4">- <span className="loading loading-spinner loading-md" />+ <Spinner /></div>) : email ? (- <button+ <Buttontype="button"- className="btn btn-soft w-full"+ variant="secondary"+ className="w-full"+ pending={isResending}onClick={() => void handleResend()}- disabled={isResending}>{isResending ? "Sending email..." : "Resend email"}- </button>+ </Button>) : null}</AuthPageCard></AuthPageShell>