feat: implement forgot password and reset password frontend
CI/CD - Build & Test / Backend Tests (push) Has been cancelled
CI/CD - Build & Test / Frontend Tests (push) Has been cancelled
CI/CD - Build & Test / Security Scans (push) Has been cancelled
CI/CD - Build & Test / Docker Build Test (push) Has been cancelled
CI/CD - Build & Test / Terraform Validate (push) Has been cancelled
Deploy to Production / Build & Test (push) Has been cancelled
Deploy to Production / Security Scan (push) Has been cancelled
Deploy to Production / Build Docker Images (push) Has been cancelled
Deploy to Production / Deploy to Staging (push) Has been cancelled
Deploy to Production / E2E Tests (push) Has been cancelled
Deploy to Production / Deploy to Production (push) Has been cancelled
E2E Tests / Run E2E Tests (push) Has been cancelled
E2E Tests / Visual Regression Tests (push) Has been cancelled
E2E Tests / Smoke Tests (push) Has been cancelled

- Add ForgotPassword page with email submission form
- Add ResetPassword page with token validation and new password form
- Extend AuthContext with requestPasswordReset and resetPassword functions
- Add routes for /forgot-password and /reset-password in App.tsx
- Update Login page to link to forgot password flow instead of showing alert

Implements Fase 1 of frontend missing features analysis
This commit is contained in:
Luca Sacchi Ricciardi
2026-04-08 00:32:40 +02:00
parent c03f66cbbf
commit 1f8d44ebfe
5 changed files with 395 additions and 11 deletions
+53 -4
View File
@@ -23,6 +23,8 @@ interface AuthContextType {
login: (email: string, password: string) => Promise<boolean>;
logout: () => void;
register: (email: string, password: string, fullName: string) => Promise<boolean>;
requestPasswordReset: (email: string) => Promise<boolean>;
resetPassword: (token: string, newPassword: string) => Promise<boolean>;
}
const AuthContext = createContext<AuthContextType | undefined>(undefined);
@@ -151,13 +153,58 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
localStorage.removeItem(REFRESH_TOKEN_KEY);
localStorage.removeItem(USER_KEY);
delete api.defaults.headers.common['Authorization'];
showToast({
title: 'Logged out',
description: 'See you soon!'
showToast({
title: 'Logged out',
description: 'See you soon!'
});
}, []);
const requestPasswordReset = useCallback(async (email: string): Promise<boolean> => {
try {
await api.post('/auth/reset-password-request', { email });
showToast({
title: 'Reset email sent',
description: 'Check your email for password reset instructions'
});
return true;
} catch (error: any) {
const message = error.response?.data?.detail || 'Failed to send reset email';
showToast({
title: 'Request failed',
description: message,
variant: 'destructive'
});
return false;
}
}, []);
const resetPassword = useCallback(async (token: string, newPassword: string): Promise<boolean> => {
try {
await api.post('/auth/reset-password', {
token,
new_password: newPassword
});
showToast({
title: 'Password reset successful',
description: 'You can now log in with your new password'
});
return true;
} catch (error: any) {
const message = error.response?.data?.detail || 'Failed to reset password';
showToast({
title: 'Reset failed',
description: message,
variant: 'destructive'
});
return false;
}
}, []);
return (
<AuthContext.Provider value={{
user,
@@ -166,6 +213,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
login,
logout,
register,
requestPasswordReset,
resetPassword,
}}>
{children}
</AuthContext.Provider>