Browse Source

🔨 Change passport email field to username

main
Haris Razis 4 years ago
parent
commit
fd02551c1b
  1. 11
      server/services/passport.js

11
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;

Loading…
Cancel
Save