From fd02551c1b648e11a33b79d86a16ea6d06c7dbac Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Fri, 25 Dec 2020 09:49:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Change=20passport=20email=20fiel?= =?UTF-8?q?d=20to=20username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/services/passport.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/services/passport.js b/server/services/passport.js index 7b0eac0..6252409 100644 --- a/server/services/passport.js +++ b/server/services/passport.js @@ -16,12 +16,15 @@ passport.deserializeUser(function (id, done) { }); passport.use('local', new LocalStrategy( - {usernameField: 'email'}, - (email, password, done) => { - User.findOne({email: email}) + { + usernameField: 'username', + passwordField: 'password' + }, + (username, password, done) => { + User.findOne({username: username}) .then(user => { if (!user) { - const newUser = new User({email, password}); + const newUser = new User({username, password}); bcrypt.genSalt(10, (err, salt) => { bcrypt.hash(newUser.password, salt, (err, hash) => { if (err) throw err;