Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block multiple form submits on application form. #4452

Merged
merged 2 commits into from
Mar 14, 2025

Conversation

frjo
Copy link
Member

@frjo frjo commented Mar 12, 2025

Fixes #4348

Before this js snippet it was possible on a slow network to post a application form multiple times by rapidly clicking the submit button multiple times.

Would be neat to use aplinejs for this everywhere but it interfere with the current "unlockApplicationForm" feature that we use to block some spam.

Test Steps

  • Set your browser to mimic a slow network and then post a application form by clicking many times in rapid succession.

@frjo frjo added Type: Enhancement This is an improvement of an existing thing (not a new thing, which would be a feature). Type: Patch Mini change, used in release drafter Status: Needs testing Tickets that need testing/qa Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team labels Mar 12, 2025
@frjo frjo temporarily deployed to test-hypha-app March 12, 2025 14:56 Inactive
@wes-otf
Copy link
Contributor

wes-otf commented Mar 12, 2025

That's super strange, I tried network throttling in Firefox but couldn't replicate. Maybe I should also try it in Safari.

I think this solution is nice! Do you think any server side validation would be worthwhile to add a hurdle to some spam attacks? Seems like something like this would be easy to script just based off this bug

@frjo
Copy link
Member Author

frjo commented Mar 12, 2025

I added the following to stop some spam years back:

const unlockApplicationForm = function () {
form.setAttribute("action", "");
button.removeAttribute("disabled");
};
// Unlock form on
// 1. mouse move
// 2. touch move
// 3. tab or enter key pressed
document.body.addEventListener("mousemove", unlockApplicationForm, {
once: true,
});
document.body.addEventListener("touchmove", unlockApplicationForm, {
once: true,
});
document.body.addEventListener(
"keydown",
function (e) {
if (e.key === "Tab" || e.key === "Enter") {
unlockApplicationForm();
}
},
{ once: true }
);

This code stops some scripts from posting since you need to move mouse/press key/touch screen before you can submit form.

Do you have more ideas how to limit spam postings?

@wes-otf
Copy link
Contributor

wes-otf commented Mar 13, 2025

I was thinking maybe a server side submit cooldown and a daily submission limit but that's out of scope of this PR, this fix seems good to me for this!

@frjo
Copy link
Member Author

frjo commented Mar 13, 2025

Yes, this is a quick fix.

For logged in users we could definitely add a check to warn/block them from submitting more than one application to each round/lab per hour or so.

We should also alert users if they have a draft belonging to a round/lab when they visit the application form.

@wes-otf wes-otf added Status: Tested - approved for live ✅ and removed Status: Needs testing Tickets that need testing/qa Status: Needs dev testing 🧑‍💻 Tasks that should be tested by the dev team labels Mar 14, 2025
@frjo frjo merged commit 0cd8fc3 into main Mar 14, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Tested - approved for live ✅ Type: Enhancement This is an improvement of an existing thing (not a new thing, which would be a feature). Type: Patch Mini change, used in release drafter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate applications being created
2 participants