signebedi / libreforms-fastapi

FastAPI implementation of the libreForms spec
GNU Affero General Public License v3.0
1 stars 1 forks source link

Is there a way to prevent duplicates? #238

Open signebedi opened 2 months ago

signebedi commented 2 months ago

One way to do this is to pass a unique ID with the client as an optional value, which can be assessed against an in memory cache.... This doesn't need to be stable, because duplicates are likely to be submitted within a short time span.

If the unique ID matches a cached unique ID, then we compare actual form data and raise an error if that matches, too.

Alternatively, we check for time-based submissions - eg. if a certain user submits a form within a short time frame, then we compare values.... but this seems less optimal than an in memory cache.

Then we can enable this if FORM_DUPLICATE_PREVENTION: bool is set to True... and we will need some kind of memcache solution... #226 also may require an in memory solution.

signebedi commented 2 months ago

Currently, in the UI, we disable the submit button on the first click... but, this is not particularly robust given that sometimes data may be submitted programmatically or even by different clients....