libreForms / libreForms-flask

Flask implementation of the libreForms API
https://libreforms.readthedocs.io
GNU Affero General Public License v3.0
4 stars 1 forks source link

[bug] duplicate forms are frequently submitted when users double click `submit` button #499

Closed signebedi closed 9 months ago

signebedi commented 9 months ago

I have a hunch that we can solve this by disabling hte submit button after the first click, see https://stackoverflow.com/a/74540125/13301284.

onClick="this.form.submit(); this.disabled=true; this.value='Submitting…'; "
signebedi commented 9 months ago

Disable Submit buttons onClick to minimize data spamming I noticed that double-clicking form submit buttons created a frustrating issue in production where form data was submitted twice to the server. I think that the problem is related to my mongodb wrapper class, not necessarily other backend tools like SQLAlchemy... but I'd like to impose a few front end fixes to help remediate the problem.

signebedi commented 9 months ago

Improve MongoDB wrapper server side duplicate validation Right now, the mongo wrapper library makes it easy for duplicate requests to make it through. We should fix this by adding some sort of validation to ensure that a duplicate has not been submitted, maybe based on the form configuration (eg. a default form config value where _allow_rapid_duplicates defaults to False)