Skip to content
Snippets Groups Projects
Commit 4ef2c6e6 authored by Gustavo Soviersovski's avatar Gustavo Soviersovski
Browse files

Expiring resetToken and passwordChange request working

parent 2df07471
No related branches found
No related tags found
1 merge request!116Release v1.0.0
...@@ -23,7 +23,8 @@ let ResetToken = new Schema({ ...@@ -23,7 +23,8 @@ let ResetToken = new Schema({
createdAt: { createdAt: {
type: Date, type: Date,
required: true, required: true,
default: Date.now default: Date.now,
expires: 86400 //Seconds in a Day
} }
}); });
......
...@@ -74,11 +74,11 @@ var UserSchema = new Schema({ ...@@ -74,11 +74,11 @@ var UserSchema = new Schema({
}); });
UserSchema.methods.encryptPassword = function(password) { UserSchema.methods.encryptPassword = function(password) {
return crypto.pbkdf2Sync(password, this.salt, 10000, 512, 'sha512'); return crypto.pbkdf2Sync(password+'', this.salt, 10000, 512, 'sha512');
}; };
UserSchema.virtual('password').set(function(password) { UserSchema.virtual('password').set(function(password) {
this._plainPassword = password; this._plainPassword = password+'';
this.salt = crypto.randomBytes(128).toString('hex'); this.salt = crypto.randomBytes(128).toString('hex');
this.hashedPassword = this.encryptPassword(password).toString('hex'); this.hashedPassword = this.encryptPassword(password).toString('hex');
}).get(function() { }).get(function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment