aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/models/User.js
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-16 00:12:14 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-16 00:12:14 +0200
commitec9a067313c3593834bc6b727429d028c43615eb (patch)
tree5db186605361593e3ad0643b5a70def9d7b0b487 /models/User.js
parentfixed regressionerror (diff)
downloadDivid-ec9a067313c3593834bc6b727429d028c43615eb.tar.gz
just some small changes
Diffstat (limited to 'models/User.js')
-rw-r--r--models/User.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/models/User.js b/models/User.js
index 216b8b0..01a6694 100644
--- a/models/User.js
+++ b/models/User.js
@@ -30,7 +30,9 @@ var UserSchema = new Schema({
facebook: {},
twitter: {},
status: { type: Number, default: 2 },
- randomToken: String
+ randomToken: String,
+ created: { type: Date, default: Date.now },
+ updated: { type: Date, default: Date.now }
});
@@ -86,10 +88,9 @@ UserSchema.path('hashed_password').validate(function(hashed_password) {
UserSchema.pre('save', function(next) {
if (!this.isNew || this.status === 1) return next();
- if(!validatePrecenceOf(this.password)
- && authTypes.indexOf(this.provider) === -1)
- next(new Error('Invalid password'));
- else next();
+ this.updated = Date.now();
+ next();
+
});
@@ -142,14 +143,15 @@ UserSchema.methods = {
* Generate random access token for Remember Me function
*
* @param {Number} length
+ * @param {Boolean} noDate
* @return {String}
* @api public
*/
- generateRandomToken: function(length) {
- if (typeof(length) === 'undefined') length = 16; // default length of token
+ generateRandomToken: function(length, noDate) {
+ if (typeof(length) === undefined) length = 16; // default length of token
var chars = '_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
- , token = new Date().getTime() + '_';
+ , token = noDate ? '' : new Date().getTime() + '_';
for (var i = 0; i < length; i++) {
var x = Math.floor(Math.random() * chars.length);
token += chars.charAt(x);