diff --git a/web/src/components/ResetPassword.tsx b/web/src/components/ResetPassword.tsx index 4c8f168..09b5366 100644 --- a/web/src/components/ResetPassword.tsx +++ b/web/src/components/ResetPassword.tsx @@ -1,28 +1,28 @@ import { useState, useEffect } from 'react'; import { resetPlatformPassword } from '../lib/authSession'; import { Button, Input } from './ui/Primitives'; - -export function ResetPassword() { - const [password, setPassword] = useState(''); - const [loading, setLoading] = useState(false); - const [message, setMessage] = useState(null); - const [error, setError] = useState(null); - - useEffect(() => { - // Handle hash fragment if present (implicit flow) - const hash = window.location.hash; - if (hash && hash.includes('type=recovery')) { - // Supabase handles the session automatically if the link is clicked - // We just need to let the user set a new password - } - }, []); - - const handlePasswordReset = async (e: React.FormEvent) => { - e.preventDefault(); - setLoading(true); - setError(null); - setMessage(null); - + +export function ResetPassword() { + const [password, setPassword] = useState(''); + const [loading, setLoading] = useState(false); + const [message, setMessage] = useState(null); + const [error, setError] = useState(null); + + useEffect(() => { + // Handle hash fragment if present (implicit flow) + const hash = window.location.hash; + if (hash && hash.includes('type=recovery')) { + // Supabase handles the session automatically if the link is clicked + // We just need to let the user set a new password + } + }, []); + + const handlePasswordReset = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading(true); + setError(null); + setMessage(null); + try { await resetPlatformPassword(password); setMessage('Password updated successfully! You can now login.'); @@ -32,19 +32,19 @@ export function ResetPassword() { } }, 2000); } catch (err: any) { - setError(err.message); - } finally { - setLoading(false); - } - }; - - return ( -
-
-

Reset Password

-

Enter your new password below

- -
+ setError(err.message); + } finally { + setLoading(false); + } + }; + + return ( +
+
+

Reset Password

+

Enter your new password below

+ +
setPassword(e.target.value)} placeholder="New password" - required - /> -
- - {error &&
{error}
} - {message &&
{message}
} - + required + /> +
+ + {error &&
{error}
} + {message &&
{message}
} + - -
- -
- ); -} + +
+ + + ); +}