Open MarvinTheParanoid opened 2 years ago
IDK if email need to be unique as it's been handled by Auth0. API to check username has been created tho. Just needs to be implemented on the front end.
No longer using Formik.
One way to do do this would be to keep and error state. On submit (or on username field blur/change) make the request set the error state with a message saying username is not unique. We could then have a some text that shows the error state if there is one set.
The DB will only accept unique usernames and emails (it will throw an error if they're not unique). We need some way to give the user feedback if the entered email and/or username is taken already.
We wouldn't want to have all usernames and emails stored in the browser for security and efficiency reasons, so we might need new api end points to check if the username/email is already taken.
Here is the Formik documentation on validation, and a related Stack overflow thread.