AOSSIE-Org / AOSSIE-Org/DebateAI
[BUG]: Reset password form shows generic "Password update failed" instead of the backend's specific error (e.g. expired code)
- Ngôn ngữ chính
- TypeScript
- Star
- 84
- Fork
- 198
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 30
Mô tả
### Bug Description
On the Reset Password form, when the backend rejects a reset attempt (e.g. an expired or invalid reset code), the form always shows the generic message **"Password update failed"** instead of the specific reason the backend returned (e.g. "Reset code has expired. Please request a new one.").
**Root cause** — field-name mismatch in `frontend/src/context/authContext.tsx` (`confirmForgotPassword`, line ~294):
```js
if (!response.ok) {
const data = await response.json();
throw new Error(data.message || 'Password update failed');
}
```
The backend returns its error under the `error` field (e.g. `{"error": "Reset code has expired. Please request a new one."}`), but the frontend reads `data.message`. Since `message` is absent, it always falls back to the generic string.
**Fix:** read `data.error` (with a sensible fallback), e.g.:
```js
throw new Error(data.error || data.message || 'Password update failed');
```
This is the same class of issue as #470 (auth errors not surfaced due to inconsistent response fields), scoped here to the reset-password flow.
cc @Ri1tik — could you assign this to me? I'm already working on the related reset-code expiry fix (#485), and the backend there returns a clear "Reset code has expired" message that this frontend change would surface properly.
### Steps to Reproduce
1. Trigger a reset failure — e.g. request a password reset code, then submit it after it's invalid/expired (or enter a wrong code).
2. The backend responds with 400 and `{"error": ""}`.
3. Observe the form displays "Password update failed" instead of the specific reason from the backend.
### Logs and Screenshots
frontend/src/context/authContext.tsx (~line 294):
throw new Error(data.message || 'Password update failed');
// backend sends { "error": "..." }, not { "message": "..." } → always falls back
### Environment Details
- File: frontend/src/context/authContext.tsx (confirmForgotPassword, ~line 294)
- Page: Reset Password form (/auth)
- Frontend: Vite + React
- Branch: main
- Related: #470 (same class — inconsistent response field); surfaces alongside #485 (reset-code expiry)
### Impact
Low - Minor inconvenience
### Code of Conduct
- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.