parse-community / parse-community/parse-dashboard

MFA login fails with "CSRF token validation failed" due to duplicate form submission

Open Beginner friendly
#3,370 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3.8k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

New Issue Checklist
Issue Description

Logging in with MFA (OTP) enabled fails with:

CSRF token validation failed. Please refresh the page and try again.

The login returns HTTP 403 with EBADCSRFTOKEN. The password step works; the failure happens on the OTP step. It reproduces on a single dashboard instance, in incognito, with no browser extensions, so it is not the multi-replica / sticky-session scenario from #3015.

Steps to reproduce
  1. Configure a dashboard user with mfa set.
  2. Open the login page, enter username + password, then the one-time password, and submit.
  3. Login fails with "CSRF token validation failed".
Actual Outcome

The OTP step issues two POST /login requests. The first authenticates successfully; Passport's req.logIn then calls req.session.regenerate() (session-fixation protection), which destroys the session that holds the CSRF token (csrf-sync stores the token in req.session). The browser cancels that first response and never receives the regenerated session cookie, so the second request lands on the now-destroyed session, finds no CSRF token, and fails validation with 403.

The duplicate submission originates in LoginForm.react.js: the submit control is type="submit" (which natively submits the form) and its onClick also calls this.formRef.current.submit(), producing a second, redundant submission. On the password step both submissions return 302, so it is harmless; only the MFA step exposes it because the first POST regenerates the session.

Expected Outcome

Login with MFA succeeds; the form is submitted exactly once.

Environment
  • Parse Dashboard version: 9.1.1 (also present on alpha / HEAD)
  • MFA: enabled (OTP)
  • Deployment: single instance (not multi-replica)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in LoginForm.react.js and trace the OTP form's submit control and onClick handler to confirm why two POST /login requests are issued. The issue is done when the MFA flow sends exactly one request and login succeeds without EBADCSRFTOKEN or a 403 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
authentication, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.