mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-27 01:29:17 +01:00
Adding the salt part to the hashPassword FN
This commit is contained in:
@@ -93,7 +93,7 @@ UserSchema.pre('save', function(next) {
|
||||
* Create instance method for hashing a password
|
||||
*/
|
||||
UserSchema.methods.hashPassword = function(password) {
|
||||
if (password) {
|
||||
if (this.salt && password) {
|
||||
return crypto.pbkdf2Sync(password, this.salt, 10000, 64).toString('base64');
|
||||
} else {
|
||||
return password;
|
||||
@@ -104,9 +104,6 @@ UserSchema.methods.hashPassword = function(password) {
|
||||
* Create instance method for authenticating user
|
||||
*/
|
||||
UserSchema.methods.authenticate = function(password) {
|
||||
if (!this.password || !this.salt) {
|
||||
return false;
|
||||
}
|
||||
return this.password === this.hashPassword(password);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user