From edcee5eb6a422b09207c4b1f090de2e28ecc7e68 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 24 Dec 2015 11:54:55 -0700 Subject: [PATCH] setNewAuthCredentials() method --- core/user.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/user.js b/core/user.js index 54edc3af..ffc0b140 100644 --- a/core/user.js +++ b/core/user.js @@ -375,6 +375,25 @@ User.prototype.persistAllProperties = function(cb) { */ }; +User.prototype.setNewAuthCredentials = function(password, cb) { + var self = this; + + generatePasswordDerivedKeyAndSalt(password, function dkAndSalt(err, info) { + if(err) { + cb(err); + } else { + var newProperties = { + pw_pbkdf2_salt : info.salt, + pw_pbkdf2_dk : info.dk, + }; + + self.persistProperties(newProperties, function persisted(err) { + cb(err); + }); + } + }); +}; + User.prototype.getAge = function() { if(_.has(this.properties, 'birthdate')) { return moment().diff(this.properties.birthdate, 'years');