Skip to content

Instantly share code, notes, and snippets.

@DomDumont
Created November 23, 2017 16:18
Show Gist options
  • Save DomDumont/4dff8e7a0be4978ed88d826d27d15ad3 to your computer and use it in GitHub Desktop.
Save DomDumont/4dff8e7a0be4978ed88d826d27d15ad3 to your computer and use it in GitHub Desktop.
signinUser: async (root, data, { mongo: { Users } }) => {
const user = await Users.findOne({ email: data.email.email });
if (user === null) {
throw new Error("Email not found !!");
}
const passwordIsGood = await bcrypt.compare(data.email.password, user.password);
if (passwordIsGood) {
return { token: `token-${user.email}`, user };
} else {
throw new Error("Bad Password !!");
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment