From 0cdca62c3650214d4b3a0f8218b50d65a53558ec Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 31 Oct 2018 16:48:09 -0400 Subject: [PATCH] add fetch() to create() --- api/helpers/passport.js | 2 +- config/protocols.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/helpers/passport.js b/api/helpers/passport.js index 61a83f8..6a1b3b8 100644 --- a/api/helpers/passport.js +++ b/api/helpers/passport.js @@ -111,7 +111,7 @@ function PassportHelper () { if (!req.user) { if (!passport) { // new user signing up, create a new user - user = await User.create(userAttrs) + user = await User.create(userAttrs).fetch() await Passport.create({ ...q, user: user.id diff --git a/config/protocols.js b/config/protocols.js index f16cfbf..5c3fe01 100644 --- a/config/protocols.js +++ b/config/protocols.js @@ -43,9 +43,10 @@ module.exports.protocols = { try { const token = generateToken() const password = user.password + if (!password.length) throw new Error('password cannot be blank') delete user.password - const newUser = User.create(user) + const newUser = await User.create(user).fetch() try { await Passport.create({ protocol: 'local',