Skip to content

[Bug]: handleResendOtp doesn't trim email before sending — inconsistent with other handlers #283

Description

@khushboo-khatoon

Before submitting

  • I have searched existing issues to make sure this is not a duplicate.
  • I have read the contribution guidelines.

Bug summary

In ForgotPassword.js, handleResendOtp sends the raw email state value to authService.resendOtp without trimming it, while the other two handlers (handleSendResetCode and handleResetPassword) both trim the email before sending. This inconsistency means a resend request could use a differently-normalized email than the original request that started the flow.

Steps to reproduce

  1. Go to the Forgot Password page .
  2. Enter an email with a leading or trailing space, e.g. via paste: " user@example.com".
  3. Submit — step 1 correctly trims and sends "user@example.com" (via authService.forgotPassword(trimmedEmail)).
  4. Proceed to step 2.
  5. Click "Resend Code".
  6. Inspect the request sent by handleResendOtp — it sends the untrimmed email (" user@example.com") instead of the trimmed value used in step 3.

Expected behavior

All three handlers (handleSendResetCode, handleResetPassword, handleResendOtp) should consistently send a trimmed email to the backend, so a resend always targets the same normalized email used in the original request.

Actual behavior

handleResendOtp sends email directly:

await authService.resendOtp(email, 'reset');

...instead of trimming it like the other two handlers do:

await authService.forgotPassword(trimmedEmail); // handleSendResetCode
await authService.resetPassword(email.trim(), ...); // handleResetPassword

If email ever contains stray whitespace (e.g. from autofill or paste), the resend request could target a different normalized string than the original, potentially causing the resend to silently fail depending on how the backend handles email lookups.

Screenshots or recordings

No response

Browser and device information

Not browser-specific — this is a logic issue in the component code (frontend/src/components/auth/ForgotPassword.js), reproducible on any browser/device.

Additional context

Suggested fix (one-line change):

  • await authService.resendOtp(email, 'reset');
  • await authService.resendOtp(email.trim(), 'reset');

Optional follow-up: derive a single trimmed value once (e.g. const trimmedEmail = email.trim();) near the top of the component and reuse it across all three handlers, to prevent this inconsistency from recurring if more handlers are added later.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions