-
Notifications
You must be signed in to change notification settings - Fork 40
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
Improved error messages #89
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ const resolvers = { | |
const { email, password } = credentials || {}; // unpack if available | ||
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"); | ||
|
||
// prevent third party using id to login when user registered | ||
if (user.email && !credentials) return new UserInputError("Email/password required to login"); | ||
|
@@ -76,7 +76,7 @@ const resolvers = { | |
|
||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand the difference. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
anon = false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect since not necessary user provided their email
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?