compdemocracy / polis

:milky_way: Open Source AI for large scale open ended feedback
https://pol.is
GNU Affero General Public License v3.0
738 stars 172 forks source link

Improve form validation errors during signup #440

Open crkrenn opened 4 years ago

crkrenn commented 4 years ago

I just noticed that if you enter a 4 character password in /createuser, polis responds with "Please enter a valid password."

Can this be made more clear?

patcon commented 4 years ago

Seems this error string comes from: https://github.com/pol-is/polis/blob/286db5f573147a6af82bf4b95b32f67263dd2d1b/client-admin/src/strings/en_us.js#L8

And that error happens here: buildCallback() of needs() https://github.com/pol-is/polis/blob/286db5f573147a6af82bf4b95b32f67263dd2d1b/server/server.js#L1524-L1531

But it seems that a more specific error code (along with others) is mentioned here, but never gets surfaced, and has no associated human-readable string: handle_POST_auth_new() https://github.com/pol-is/polis/blob/286db5f573147a6af82bf4b95b32f67263dd2d1b/server/server.js#L6774-L6777

If someone feels like testing this out, I feel like the fix might have something to do with running next(e) with the error code raised, instead of next(s) with a generic message. Some human-readable strings would need to be added for these error conditions.

This could also do with some e2e tests to confirm all these vaidations. Happy to help someone write those after the issue gets sorted :)