- {
- e.preventDefault();
- // TODO: Implement forgot password
- alert('Forgot password - Coming soon');
- }}
>
Forgot password?
diff --git a/frontend/src/pages/ResetPassword.tsx b/frontend/src/pages/ResetPassword.tsx
new file mode 100644
index 0000000..d491454
--- /dev/null
+++ b/frontend/src/pages/ResetPassword.tsx
@@ -0,0 +1,205 @@
+import { useState, useEffect } from 'react';
+import { Link, useSearchParams, useNavigate } from 'react-router-dom';
+import { useAuth } from '@/contexts/AuthContext';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
+import { Cloud, Loader2, CheckCircle, AlertCircle } from 'lucide-react';
+
+export function ResetPassword() {
+ const [searchParams] = useSearchParams();
+ const navigate = useNavigate();
+ const token = searchParams.get('token');
+
+ const [password, setPassword] = useState('');
+ const [confirmPassword, setConfirmPassword] = useState('');
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [isSuccess, setIsSuccess] = useState(false);
+ const [error, setError] = useState(null);
+ const { resetPassword } = useAuth();
+
+ // Redirect if no token
+ useEffect(() => {
+ if (!token) {
+ setError('Invalid or missing reset token. Please request a new password reset.');
+ }
+ }, [token]);
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+ setError(null);
+
+ if (password !== confirmPassword) {
+ setError('Passwords do not match');
+ return;
+ }
+
+ if (password.length < 8) {
+ setError('Password must be at least 8 characters long');
+ return;
+ }
+
+ setIsSubmitting(true);
+
+ const success = await resetPassword(token!, password);
+ if (success) {
+ setIsSuccess(true);
+ // Redirect to login after 3 seconds
+ setTimeout(() => {
+ navigate('/login');
+ }, 3000);
+ }
+
+ setIsSubmitting(false);
+ };
+
+ if (!token) {
+ return (
+
+
+
+
+ mockupAWS
+
+
+
+
+
+
+
+ Invalid Link
+
+ {error}
+
+
+
+
+
+
+
+ Back to sign in
+
+
+
+
+
+ );
+ }
+
+ if (isSuccess) {
+ return (
+
+
+
+
+ mockupAWS
+
+
+
+
+
+
+
+ Password reset successful
+
+ Your password has been reset successfully. You will be redirected to the login page in a few seconds.
+
+
+
+
+
+
+
+
+
+
+ );
+ }
+
+ return (
+
+
+
+
+ mockupAWS
+
+
+
+
+ Set new password
+
+ Enter your new password below
+
+
+
+
+