Skip to content

fix(auth): add forgot password page#147

Open
Divv1524 wants to merge 2 commits into
rdodiya:gssoc_developfrom
Divv1524:fix/forgot-password-route
Open

fix(auth): add forgot password page#147
Divv1524 wants to merge 2 commits into
rdodiya:gssoc_developfrom
Divv1524:fix/forgot-password-route

Conversation

@Divv1524
Copy link
Copy Markdown

@Divv1524 Divv1524 commented May 17, 2026

Issue Link

Closes #82

Changes Made

  • Added a functional /forgot-password page matching the existing auth UI.
  • Integrated forgot password API call with /public/api/v1/auth/forgot-password.
  • Added validation, loading, success, retry, and API error states.
  • Wrapped the actual frontend entry point with GoogleOAuthProvider so the login page renders correctly and the forgot password link can be used.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactor

Testing Performed

Frontend Testing

  • Component renders correctly
  • Responsive layout checked through browser route testing
  • No new console errors on forgot-password flow
  • Production build passed

Test Cases:

  • Direct /forgot-password route renders reset form.
  • Empty email shows required validation and does not call API.
  • Invalid email shows format validation and does not call API.
  • Whitespace-only email is treated as empty.
  • Valid email is trimmed before API submission.
  • API success: false response shows inline error.
  • HTTP error response shows backend error message.
  • Successful API response shows confirmation message.
  • “Try another email” returns to the form.
  • Login page “Forgot Password?” link navigates to /forgot-password.

UI/UX Changes

  • Added forgot password screen consistent with login/register design.
  • Added inline success and error states.

Additional Notes

  • npm.cmd run build passes.
  • npm.cmd run lint could not run because the repo does not currently include an ESLint 9 eslint.config.js file.

@rdodiya
Copy link
Copy Markdown
Owner

rdodiya commented May 19, 2026

Hi @Divv1524 ,
Please resolve conflicts

@rdodiya
Copy link
Copy Markdown
Owner

rdodiya commented May 19, 2026

Hi @Divv1524 ,
Please resolve conflicts and ensure that the forgot password frontend should follow the below flow,
#117 (comment)

If possible please integrate the Frontend with backend api created in #117

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a functional forgot/reset password UI for the public auth flow, replacing the previous placeholder screen.

Changes:

  • Replaced the placeholder ForgotPassword page with a multi-step flow (request reset code → submit code + new password → completion state).
  • Added client-side validation (Formik + Yup), loading states, and inline success/error messaging.
  • Integrated API calls for forgot-password and reset-password via the shared Axios client.
Comments suppressed due to low confidence (1)

RestroHub-FrontEnd/src/pages/public/ForgotPassword.jsx:222

  • The reset-password catch block has the same issue as the request step: getApiMessage(..., fallback) returns a non-empty fallback when err.response is absent, preventing err.message (including messages from locally thrown Errors) from being displayed. Reorder the fallback logic so err.message is used when there is no backend response message.
      } catch (err) {
        const message =
          getApiMessage(err.response?.data, "Password reset failed.") ||
          err.message ||
          "Password reset failed.";


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +168 to +176
} catch (err) {
const message =
getApiMessage(
err.response?.data,
"Unable to send reset instructions. Please try again."
) ||
err.message ||
"Unable to send reset instructions. Please try again.";

Comment on lines +197 to +202
const res = await api.post("/public/api/v1/auth/reset-password", null, {
params: {
email: requestedEmail,
token: token.trim(),
newPassword,
},
<p className="mb-8 text-sm leading-6 text-gray-500 dark:text-gray-400">
{step === "request"
? "Enter your registered email address and we will send a reset code."
: "Use the reset code sent to your email and choose a new password."}
@rdodiya
Copy link
Copy Markdown
Owner

rdodiya commented May 20, 2026

Hi @Divv1524 ,
Please review the suggestions

integratethe changes from backend and frontend for forgot password page
@Divv1524 Divv1524 force-pushed the fix/forgot-password-route branch from d52e665 to 67007f8 Compare May 21, 2026 05:37
@Divv1524
Copy link
Copy Markdown
Author

Hi @Divv1524 , Please review the suggestions

Hi @rdodiya,

Reviewed and addressed the Copilot suggestions:

  • Fixed error message fallback order so API/local thrown errors are shown correctly.
  • Updated reset-password request to send email, token, and newPassword in a form-encoded POST body instead of query params, avoiding password leakage in URLs while staying compatible with Spring @RequestParam.
  • Added explicit completion-state helper text.

Testing:

  • npm.cmd run build passed
  • Verified forgot/reset password browser flow
  • Verified invalid token error displays correctly
  • Verified newPassword is sent in request body, not query params

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forgot password route is missing

3 participants