Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(auth): wire the full reset-password flow (#151) (#171)

Gökhan Geyik289847a7faf8
diff --git a/web/messages/en.json b/web/messages/en.json
index c52e801ea..18a9cf67f 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -49,6 +49,19 @@
"magicLinkSent": "Check your email for the sign-in link.",
"verificationEmailSent": "We sent you a verification email. Check your inbox to confirm your account.",
"verificationPending": "We sent a verification email to your inbox. Please click the link to verify your account before signing in.",
+ "forgotPasswordTitle": "Reset your password",
+ "forgotPasswordSubtitle": "Enter your email and we'll send you a link to reset your password.",
+ "sendResetLink": "Send reset link",
+ "sendingResetLink": "Sending...",
+ "resetLinkSent": "If that email exists, we've sent a reset link. Check your inbox.",
+ "backToSignIn": "Back to sign in",
+ "resetPasswordTitle": "Set a new password",
+ "resetPasswordSubtitle": "Choose a new password for your account.",
+ "newPassword": "New password",
+ "confirmPassword": "Confirm password",
+ "updatePassword": "Update password",
+ "updatingPassword": "Updating...",
+ "passwordUpdated": "Your password has been updated. You can now sign in.",
"orContinueWith": "Or continue with",
"termsAgreement": "By continuing, you agree to our",
"termsOfService": "Terms of Service",
@@ -59,6 +72,7 @@
"emailRequired": "Email is required.",
"passwordRequired": "Password is required.",
"passwordTooShort": "Password must be at least 8 characters.",
+ "passwordMismatch": "Passwords do not match.",
"generic": "An error occurred. Please try again.",
"emailNotConfirmed": "Please verify your email address first. Check your inbox for the confirmation link.",
"signOutError": "Failed to sign out. Please try again."
diff --git a/web/src/app/[locale]/(marketing)/forgot-password/page.tsx b/web/src/app/[locale]/(marketing)/forgot-password/page.tsx
new file mode 100644
index 000000000..c6a82abf0
--- /dev/null
+++ b/web/src/app/[locale]/(marketing)/forgot-password/page.tsx
@@ -0,0 +1,26 @@
+import { useTranslations } from 'next-intl';
+import { ForgotPasswordForm } from '@/components/auth/forgot-password-form';
+
+export default function ForgotPasswordPage() {
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10">
+ <div className="flex w-full max-w-sm flex-col gap-6">
+ <ForgotPasswordCard />
+ </div>
+ </div>
+ );
+}
+
+function ForgotPasswordCard() {
+ const t = useTranslations('auth');
+
+ return (
+ <div className="rounded-xl border bg-card p-6 shadow-sm">
+ <div className="mb-6 text-center">
+ <h1 className="text-2xl font-semibold tracking-tight">{t('forgotPasswordTitle')}</h1>
+ <p className="mt-1 text-sm text-muted-foreground">{t('forgotPasswordSubtitle')}</p>
+ </div>
+ <ForgotPasswordForm />
+ </div>
+ );
+}
diff --git a/web/src/app/[locale]/(marketing)/reset-password/page.tsx b/web/src/app/[locale]/(marketing)/reset-password/page.tsx
new file mode 100644
index 000000000..b31e184df
--- /dev/null
+++ b/web/src/app/[locale]/(marketing)/reset-password/page.tsx
@@ -0,0 +1,26 @@
+import { useTranslations } from 'next-intl';
+import { ResetPasswordForm } from '@/components/auth/reset-password-form';
+
+export default function ResetPasswordPage() {
+ return (
+ <div className="flex min-h-svh flex-col items-center justify-center gap-6 p-6 md:p-10">
+ <div className="flex w-full max-w-sm flex-col gap-6">
+ <ResetPasswordCard />
+ </div>
+ </div>
+ );
+}
+
+function ResetPasswordCard() {
+ const t = useTranslations('auth');
+
+ return (
+ <div className="rounded-xl border bg-card p-6 shadow-sm">
+ <div className="mb-6 text-center">
+ <h1 className="text-2xl font-semibold tracking-tight">{t('resetPasswordTitle')}</h1>
+ <p className="mt-1 text-sm text-muted-foreground">{t('resetPasswordSubtitle')}</p>
+ </div>
+ <ResetPasswordForm />
+ </div>
+ );
+}
diff --git a/web/src/components/auth/forgot-password-form.tsx b/web/src/components/auth/forgot-password-form.tsx
new file mode 100644
index 000000000..df6ad8d1f
--- /dev/null
+++ b/web/src/components/auth/forgot-password-form.tsx
@@ -0,0 +1,86 @@
+'use client';
+
+import { useState } from 'react';
+import { useTranslations } from 'next-intl';
+import { Link } from '@/i18n/navigation';
+import { createClient } from '@/lib/supabase/client';
+import { Button, buttonVariants } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Loader2, MailCheck } from 'lucide-react';
+
+export function ForgotPasswordForm() {
+ const t = useTranslations('auth');
+ const [email, setEmail] = useState('');
+ const [isLoading, setIsLoading] = useState(false);
+ const [submitted, setSubmitted] = useState(false);
+
+ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
+ e.preventDefault();
+ setIsLoading(true);
+
+ const supabase = createClient();
+ const appUrl = process.env.NEXT_PUBLIC_APP_URL?.replace(/\/$/, '') ?? window.location.origin;
+
+ await supabase.auth.resetPasswordForEmail(email, {
+ redirectTo: `${appUrl}/auth/confirm?next=/reset-password`,
+ });
+
+ // Always show the generic success state regardless of whether the email is
+ // registered — prevents account enumeration.
+ setIsLoading(false);
+ setSubmitted(true);
+ }
+
+ if (submitted) {
+ return (
+ <div className="space-y-4">
+ <div className="flex items-start gap-3 rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-900 dark:bg-blue-950/50">
+ <MailCheck className="mt-0.5 h-5 w-5 shrink-0 text-blue-600 dark:text-blue-400" />
+ <p className="text-sm text-blue-800 dark:text-blue-300">{t('resetLinkSent')}</p>
+ </div>
+ <Link
+ href="/sign-in"
+ className={buttonVariants({ variant: 'outline', className: 'w-full' })}
+ >
+ {t('backToSignIn')}
+ </Link>
+ </div>
+ );
+ }
+
+ return (
+ <form onSubmit={handleSubmit} className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="email">{t('email')}</Label>
+ <Input
+ id="email"
+ type="email"
+ placeholder={t('emailPlaceholder')}
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ required
+ autoComplete="email"
+ disabled={isLoading}
+ />
+ </div>
+
+ <Button type="submit" className="w-full" disabled={isLoading}>
+ {isLoading ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ {t('sendingResetLink')}
+ </>
+ ) : (
+ t('sendResetLink')
+ )}
+ </Button>
+
+ <p className="text-center text-sm text-muted-foreground">
+ <Link href="/sign-in" className="underline-offset-4 hover:text-primary hover:underline">
+ {t('backToSignIn')}
+ </Link>
+ </p>
+ </form>
+ );
+}
diff --git a/web/src/components/auth/reset-password-form.tsx b/web/src/components/auth/reset-password-form.tsx
new file mode 100644
index 000000000..47b6cddb5
--- /dev/null
+++ b/web/src/components/auth/reset-password-form.tsx
@@ -0,0 +1,92 @@
+'use client';
+
+import { useState } from 'react';
+import { useTranslations } from 'next-intl';
+import { useRouter } from '@/i18n/navigation';
+import { createClient } from '@/lib/supabase/client';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { toast } from 'sonner';
+import { Loader2 } from 'lucide-react';
+
+export function ResetPasswordForm() {
+ const t = useTranslations('auth');
+ const router = useRouter();
+ const [password, setPassword] = useState('');
+ const [confirm, setConfirm] = useState('');
+ const [isLoading, setIsLoading] = useState(false);
+
+ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
+ e.preventDefault();
+
+ if (password.length < 8) {
+ toast.error(t('errors.passwordTooShort'));
+ return;
+ }
+
+ if (password !== confirm) {
+ toast.error(t('errors.passwordMismatch'));
+ return;
+ }
+
+ setIsLoading(true);
+ const supabase = createClient();
+
+ const { error } = await supabase.auth.updateUser({ password });
+
+ if (error) {
+ toast.error(t('errors.generic'));
+ setIsLoading(false);
+ return;
+ }
+
+ toast.success(t('passwordUpdated'));
+ await supabase.auth.signOut();
+ router.push('/sign-in');
+ router.refresh();
+ }
+
+ return (
+ <form onSubmit={handleSubmit} className="space-y-4">
+ <div className="space-y-2">
+ <Label htmlFor="password">{t('newPassword')}</Label>
+ <Input
+ id="password"
+ type="password"
+ placeholder={t('passwordPlaceholder')}
+ value={password}
+ onChange={(e) => setPassword(e.target.value)}
+ required
+ autoComplete="new-password"
+ disabled={isLoading}
+ />
+ </div>
+
+ <div className="space-y-2">
+ <Label htmlFor="confirmPassword">{t('confirmPassword')}</Label>
+ <Input
+ id="confirmPassword"
+ type="password"
+ placeholder={t('passwordPlaceholder')}
+ value={confirm}
+ onChange={(e) => setConfirm(e.target.value)}
+ required
+ autoComplete="new-password"
+ disabled={isLoading}
+ />
+ </div>
+
+ <Button type="submit" className="w-full" disabled={isLoading}>
+ {isLoading ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ {t('updatingPassword')}
+ </>
+ ) : (
+ t('updatePassword')
+ )}
+ </Button>
+ </form>
+ );
+}
diff --git a/web/src/components/auth/sign-in-form.tsx b/web/src/components/auth/sign-in-form.tsx
index e63f8f6c1..a35feee03 100644
--- a/web/src/components/auth/sign-in-form.tsx
+++ b/web/src/components/auth/sign-in-form.tsx
@@ -3,7 +3,7 @@
import { useState } from 'react';
import { useTranslations } from 'next-intl';
import { useSearchParams } from 'next/navigation';
-import { useRouter } from '@/i18n/navigation';
+import { useRouter, Link } from '@/i18n/navigation';
import { createClient } from '@/lib/supabase/client';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -86,12 +86,12 @@ export function SignInForm() {
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label htmlFor="password">{t('password')}</Label>
- <a
- href="#"
+ <Link
+ href="/forgot-password"
className="text-sm text-muted-foreground hover:text-primary underline-offset-4 hover:underline"
>
{t('forgotPassword')}
- </a>
+ </Link>
</div>
<Input
id="password"