From ec9a067313c3593834bc6b727429d028c43615eb Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Thu, 16 May 2013 00:12:14 +0200 Subject: just some small changes --- models/User.js | 18 ++++++++++-------- views/navbar.ejs | 2 +- views/signup.ejs | 16 ++++++++++------ 3 files changed, 21 insertions(+), 15 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); diff --git a/views/navbar.ejs b/views/navbar.ejs index 12d3e26..785c2bf 100644 --- a/views/navbar.ejs +++ b/views/navbar.ejs @@ -14,7 +14,7 @@
- +
diff --git a/views/signup.ejs b/views/signup.ejs index 01a5831..c058402 100644 --- a/views/signup.ejs +++ b/views/signup.ejs @@ -19,7 +19,11 @@
- + <% if (invite) { %> + <%= email %> + <% } else { %> + + <% } %>

@@ -57,11 +61,11 @@
- - - - - + + + + +