Created
November 23, 2017 16:18
-
-
Save DomDumont/4dff8e7a0be4978ed88d826d27d15ad3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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