Skip to content

Instantly share code, notes, and snippets.

@lubien
Forked from viniazvd/service.js
Last active December 3, 2017 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lubien/d543a56aaea120a3ff043aa6d6aa1ece to your computer and use it in GitHub Desktop.
Save lubien/d543a56aaea120a3ff043aa6d6aa1ece to your computer and use it in GitHub Desktop.
module.exports = {
async signup(name, email, password) {
const exists = await models.user.findOne({ where: { email } })
if (exists) {
throw new Error({ error: 'E-mail já existe. Tente se registrar com outro.' })
}
const passwordEncrypted = await hashing(password)
const user = await models.user.build({ name, email, password: passwordEncrypted })
await user.save()
return { user }
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment