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
You can add a UNIQUE specifier in your SQL database to prevent multiple occurrences of the same username. This would save having so much logic in the handleRegister() function and allow you to make the code more efficient without polling the database to find all users and then see if they exist already. (although nice job on implementing all this functionality and making it work)
Your SQL would just be like this:
CREATE TABLE IF NOT EXISTS users (
user_id SERIAL PRIMARY KEY,
user_name VARCHAR(50) NOT NULL UNIQUE,
user_hash VARCHAR(100) NOT NULL
);
and then why you try and add a user you can just handle the error if the user exists instead of so much code for verifying stuff.
The text was updated successfully, but these errors were encountered:
You could use the functionality you've built to check in the front end to prevent the form being submitted and send them an error message if the username is not unique
You can add a
UNIQUE
specifier in your SQL database to prevent multiple occurrences of the same username. This would save having so much logic in thehandleRegister()
function and allow you to make the code more efficient without polling the database to find all users and then see if they exist already.(although nice job on implementing all this functionality and making it work)
Your SQL would just be like this:
and then why you try and add a user you can just handle the error if the user exists instead of so much code for verifying stuff.
The text was updated successfully, but these errors were encountered: