Block double-submission of registration form#5161
Block double-submission of registration form#5161nucleogenesis wants to merge 1 commit intolearningequality:hotfixesfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR prevents users from accidentally submitting the registration form multiple times by introducing a submitting flag and guarding the submit() method.
- Adds a
submittingdata property to track in‐flight submissions - Early‐exit in
submit()if a submission is already in progress - Resets
submittingon error and after the submit logic
| this.submitting = false; | ||
| }); | ||
| } else if (this.$refs.top.scrollIntoView) { | ||
| this.$refs.top.scrollIntoView({ behavior: 'smooth' }); | ||
| } | ||
| this.submitting = false; |
There was a problem hiding this comment.
Resetting submitting immediately after dispatch call (outside of its promise handlers) allows the button to re-enable before the request completes. Move this reset into a finally block on the dispatch promise or remove this unconditional reset so the flag only clears after success or failure.
| this.submitting = false; | |
| }); | |
| } else if (this.$refs.top.scrollIntoView) { | |
| this.$refs.top.scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| this.submitting = false; | |
| }) | |
| .finally(() => { | |
| this.submitting = false; | |
| }); | |
| } else if (this.$refs.top.scrollIntoView) { | |
| this.$refs.top.scrollIntoView({ behavior: 'smooth' }); | |
| } |
| this.$refs.top.scrollIntoView({ behavior: 'smooth' }); | ||
| } | ||
| this.submitting = false; | ||
| return Promise.resolve(); |
There was a problem hiding this comment.
Returning Promise.resolve() prevents callers from awaiting the actual registration request. Instead, return the this.$store.dispatch(...) promise (chained with .finally(...)) so consumers can rely on the real submission lifecycle.
| return Promise.resolve(); | |
| return Promise.reject(new Error('Validation failed or agreement not accepted')); |
|
From the issue:
Need to add backend changes here to achieve the above, and also add a regression test for this behaviour. |
|
Original issue has been unassigned, so going to close this for now. |
Summary
When a user double-clicks the Submit button during account creation, the subsequent requests after the first cause a database error as reported in #4779
This introduces a simple data property
submittingto track if the user has submitted the form and ensures it is unset when an error occurs, reenabling the submit button.References
Closes #4779
Reviewer guidance
1
2