Openfoodnetwork: /register allows submitting multiple times while the enterprise is still being created

Created on 31 Aug 2017  路  3Comments  路  Source: openfoodfoundation/openfoodnetwork

What?

From the registration wizard in /register users are allowed to submit the create profile form multiple times while the first request didn't finish yet. This causes an alert dialog to appear with a somewhat clunky error message, totally unexpected for the user.

I managed to reproduce the issue by adding a breakpoint in https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/api/enterprises_controller.rb#L17

See the screenshot below. I successfully made 4 requests while I didn't get a first response.

create_profile

The first one creates the enterprise but the others raise a validation error as expected. This however is a bit confusing for the user in terms of UX, especially given the error message in the alert above.

It's also not clear what the state of the enterprise is (in the database) after the error shows up. In a real scenario with an actual user, as we weren't sure, we started the registration from scratch.

To avoid this situation, I suggest we disable the Create Profile button until we receive the response.

https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/assets/javascripts/darkswarm/services/enterprise_registration_service.js.coffee#L14 is apparently the function that implements this behavior.

Most helpful comment

@daniellemoorhead I think this quick change to the button behaviour won't be any problem for the email confirmation branches.

All 3 comments

@Matt-Yorkley is it worth waiting until the email confirm functionality is live before fixing this?

@daniellemoorhead I believe it's a 5min change, so unless email confirmation is ready I'd fix it.

@daniellemoorhead I think this quick change to the button behaviour won't be any problem for the email confirmation branches.

Was this page helpful?
0 / 5 - 0 ratings