feat: Add option otpAutoSubmit to control auto-submitting the login form after entering a one-time password - #3448
Conversation
… form after entering a one-time password With MFA enabled, the login form is submitted automatically as soon as the entered one-time password reaches the expected length. This behavior is hardcoded and cannot be disabled, which means a user has no chance to review or correct the code before it is submitted; a single mistyped digit causes a failed login and a full page reload. Adds a new root-level option `otpAutoSubmit` (default `true`) that gates the behavior. Existing installations are unaffected; setting it to `false` requires the user to submit the login form manually. The option is passed to the login page by injecting a `PARSE_DASHBOARD_OTP_AUTO_SUBMIT` global into the page shell, following the existing `enableResourceCache` pattern. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe dashboard adds the ChangesOTP auto-submit
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This adds a documented OTP auto-submit setting while preserving automatic submission by default; disabling it requires manual form submission. No current merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant DashboardConfig
participant LoginPage
participant User
participant LoginForm
DashboardConfig->>LoginPage: embed OTP auto-submit setting
LoginPage->>LoginForm: initialize login behavior
User->>LoginForm: enter complete OTP
LoginForm->>LoginForm: submit automatically when enabled
Suggested reviewers: 🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@mtrezza Could you please approve the ci workflow run so the workflows can execute? Thanks! |
Pull Request
Issue
When a user has MFA enabled, the login form is submitted automatically as soon as the entered one-time password reaches the expected length. This was introduced in e528705 (#2257) and is currently hardcoded with no way to opt out.
That is convenient in the common case, but there is no way to disable it, and the behavior is problematic in a few situations:
There is currently no configuration option to turn this off.
Approach
Adds a new root-level dashboard option
otpAutoSubmit(Boolean, defaulttrue) that controls whether the login form is auto-submitted once a complete one-time password has been entered.true/ omitted — current behavior, unchanged. This is fully backwards compatible; existing installations are not affected.false— the one-time password field no longer triggers a submit; the user submits the form manually.The option is plumbed to the login page following the existing
enableResourceCachepattern, which is the established way this repository passes configuration to frontend code:Parse-Dashboard/app.js— the/loginroute injectsPARSE_DASHBOARD_OTP_AUTO_SUBMITinto the page shell, next to the existingPARSE_DASHBOARD_PATHglobal. The check isconfig.otpAutoSubmit === falserather than a truthy test, so that only an explicitfalsedisables the feature and any other value (including an absent key) keeps the current default.src/login/Login.js— reads the global once in the constructor aswindow.PARSE_DASHBOARD_OTP_AUTO_SUBMIT !== falseand adds it to the existing auto-submit guard inupdateField. Defaulting totruewhen the global isundefinedkeeps the component behaving correctly if it is ever mounted outside the server-rendered shell.The auto-submit mechanism itself is deliberately left untouched to keep the diff minimal and easy to review; this PR only gates it.
Because the option is a plain root-level config key, it works across all integration styles with no extra plumbing — the Express middleware (
new ParseDashboard({ otpAutoSubmit: false, ... })), a--configfile, and thePARSE_DASHBOARD_CONFIGenvironment variable. No new CLI flag or environment variable is introduced.Example configuration:
{ "apps": [{ "...": "..." }], "otpAutoSubmit": false, "users": [ { "user": "user1", "pass": "pass", "mfa": "lmvmOIZGMTQklhOIhveqkumss" } ] }Tasks
Tests
src/lib/tests/OtpAutoSubmit.test.jsmounts the dashboard over a real HTTP server and asserts the value rendered into the login page for all three states — option omitted,true, andfalse. It follows the existingsrc/lib/tests/RemoteAccess.test.jspattern.Note that Jest
rootsis limited tosrc/liband no jsdom environment is configured for this suite, so the flag is verified at the server-rendered boundary rather than by rendering the React component.Documentation
otpAutoSubmitto the Root Options table inREADME.md.Summary by CodeRabbit
New Features
otpAutoSubmitlogin configuration option, enabled by default.Documentation
Tests