Browse Source

Add registered on user model

main
Haris Razis 4 years ago
parent
commit
c8db520078
  1. 2
      server/models/User.js
  2. 3
      server/services/passport.js

2
server/models/User.js

@ -5,7 +5,7 @@ const userSchema = new Schema({
username: String, username: String,
email: String, email: String,
password: String, password: String,
registered: String, registered: Date,
lastLogin: Date lastLogin: Date
}); });

3
server/services/passport.js

@ -25,7 +25,8 @@ passport.use('local', new LocalStrategy(
.then(user => { .then(user => {
if (!user) { if (!user) {
const lastLogin = Date.now() const lastLogin = Date.now()
const newUser = new User({username, password, lastLogin}); const registered = lastLogin
const newUser = new User({username, password, registered, lastLogin});
bcrypt.genSalt(10, (err, salt) => { bcrypt.genSalt(10, (err, salt) => {
bcrypt.hash(newUser.password, salt, (err, hash) => { bcrypt.hash(newUser.password, salt, (err, hash) => {
if (err) throw err; if (err) throw err;

Loading…
Cancel
Save