You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Chapter 11: Spamming 'Create Invoice' or 'Edit Invoice' multiple times leads to duplicate creates/edits #1326
After implementing both the create and edit invoice sections (Chapter 11), I decided to just kind of mess around and test the current state of my app. I've followed the chapters to the letter and everything is functioning fine.
Issue: When I go to create an invoice, after filling out the information, I can spam click the "Create Invoice" submit button multiple times sending equal number of POST requests to the server/database resulting in duplicate entries in the database BEFORE the router routes me back to /dashboard/invoices.
I get this is just a tutorial, so it's not that serious. A simple fix would be to just disable the button after the first click. It's not so crazy with Edit invoice, but I can still see the multiple SQL queries, so having a class that can be utilized for both create & edit would be nice.
I've "talked" to my good friend Claude Sonnet and this is what she came up with:
Expected: Only 1 invoice to be created with 3 button clicks of "Create Invoice".
Actual: Three duplicate invoices were created. Checkout the screenshot.
Activity