Skip to content

We have to check first user is present or not #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Shrikant-Surwase
Copy link

We have to check the username is present or not then and then we have to create new entry in our database

We need to check first if username is present or not.
@@ -14,7 +14,12 @@ export const singupUser = async (request, response) => {
const hashedPassword = await bcrypt.hash(request.body.password, 10);

const user = { username: request.body.username, name: request.body.name, password: hashedPassword }

//we need to first check if user already present or not if present then we have to throw an error otherwise we have
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move these lines above the password hashing step because if the username already exists, there's no benefit in hashing the password if we're not going to save the user details in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants