Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Member

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

Copy link
Author

@ItsAdityaKSingh ItsAdityaKSingh Jan 21, 2022

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?


// prevent third party using id to login when user registered
if (user.email && !credentials) return new UserInputError("Email/password required to login");
Expand All @@ -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");
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand the difference.

Copy link
Author

Choose a reason for hiding this comment

The 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;
}

Expand Down