Last active
November 22, 2017 15:03
-
-
Save DomDumont/cbd0ff279e534ed6219d34f45ab5af92 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
createUser: async (root, data, { mongo: { Users } }) => { | |
const user = await Users.findOne({ email: data.authProvider.email.email }); | |
if (user) { | |
// a user with the same email was found, throw an error | |
throw new Error("Email already exists"); | |
} | |
const newUser = { | |
name: data.name, | |
email: data.authProvider.email.email, | |
password: data.authProvider.email.password, // todo this is really bad, do not store password in clear | |
}; | |
const response = await Users.insert(newUser); | |
return { id: response.insertedIds[0], ...newUser }; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment