From 5907d86467eb00b7c9184434600108b27b4cce93 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Wed, 21 Jan 2026 04:06:08 -0300 Subject: [PATCH] feat: [US-009] - Password reset - forgot password page Co-Authored-By: Claude Opus 4.5 --- src/app/forgot-password/page.tsx | 120 +++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 src/app/forgot-password/page.tsx diff --git a/src/app/forgot-password/page.tsx b/src/app/forgot-password/page.tsx new file mode 100644 index 0000000..ffcb289 --- /dev/null +++ b/src/app/forgot-password/page.tsx @@ -0,0 +1,120 @@ +'use client' + +import { useState } from 'react' +import Link from 'next/link' +import { createClient } from '@/lib/supabase/client' + +export default function ForgotPasswordPage() { + const [email, setEmail] = useState('') + const [error, setError] = useState(null) + const [success, setSuccess] = useState(false) + const [loading, setLoading] = useState(false) + + async function handleSubmit(e: React.FormEvent) { + e.preventDefault() + setError(null) + setLoading(true) + + const supabase = createClient() + + const { error } = await supabase.auth.resetPasswordForEmail(email, { + redirectTo: `${window.location.origin}/reset-password`, + }) + + if (error) { + setError(error.message) + setLoading(false) + return + } + + setSuccess(true) + setLoading(false) + } + + if (success) { + return ( +
+
+
+

+ Check your email +

+

+ We've sent a password reset link to {email}. + Please check your inbox and follow the instructions to reset your password. +

+
+ +
+ + Back to sign in + +
+
+
+ ) + } + + return ( +
+
+
+

+ Forgot your password? +

+

+ Enter your email address and we'll send you a link to reset your password. +

+
+ +
+ {error && ( +
+

{error}

+
+ )} + +
+ + setEmail(e.target.value)} + className="mt-1 block w-full rounded-md border border-zinc-300 bg-white px-3 py-2 text-zinc-900 placeholder-zinc-400 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-50 dark:placeholder-zinc-500" + placeholder="you@example.com" + /> +
+ + + +
+ + Back to sign in + +
+
+
+
+ ) +}