Conversation
| const user = id ? await User.findById(id) : await User.findOne({ email }); | ||
|
|
||
| if (!user) return new Error("User not found."); | ||
| if (!user) return new Error("No account registered with this email"); |
There was a problem hiding this comment.
incorrect since not necessary user provided their email
There was a problem hiding this comment.
We are using a validator in the front-end to ensure no email having a null value is passed while logging in or signing up. Are you sure I should remove this change?
| if (credentials) { | ||
| const valid = email === user.email && (await bcrypt.compare(password, user.password)); | ||
| if (!valid) return new AuthenticationError("credentials don't match"); | ||
| if (!valid) return new AuthenticationError("Enter a valid password"); |
There was a problem hiding this comment.
I'm not sure I understand the difference.
There was a problem hiding this comment.
Wrong credentials could mean a wrong email or password or both. Giving a hint that it's just the wrong password here could prove useful.
|
Can the frontend not parse these errors and display them however they see fit? |
Yes, we could try that. But right now, the error returned from the backend is being shown on the screen. However, having these minute changes may help in bettering the backend too :) |
fixes #88
Some error messages being thrown couldn't classify what was going wrong. I tried fixing it. Once fixed, here would reflect in the beacon app as well!