From 1891d1fe7563622c2bff72a0500cd4e5396e95b2 Mon Sep 17 00:00:00 2001 From: Aysel Afsar Date: Mon, 11 Apr 2016 09:43:22 -0400 Subject: [PATCH] Check whether priorLoginDate is undefined --- Packages/active-entry/lib/ActiveEntry.js | 2 ++ Packages/active-entry/server/methods.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Packages/active-entry/lib/ActiveEntry.js b/Packages/active-entry/lib/ActiveEntry.js index de1d4bab7..1a15fa509 100755 --- a/Packages/active-entry/lib/ActiveEntry.js +++ b/Packages/active-entry/lib/ActiveEntry.js @@ -367,6 +367,8 @@ ActiveEntry.resetPassword = function(passwordValue, confirmPassword) { return; } Session.set('_resetPasswordToken', null); + // Update last login time + Meteor.call("updateLastLoginDate"); var ActiveEntryConfig = Session.get('Photonic.ActiveEntry'); Router.go(ActiveEntryConfig.signIn.destination); }); diff --git a/Packages/active-entry/server/methods.js b/Packages/active-entry/server/methods.js index 5225148e9..f11a5e7bc 100644 --- a/Packages/active-entry/server/methods.js +++ b/Packages/active-entry/server/methods.js @@ -127,8 +127,12 @@ Meteor.methods({ if (!user) { return; } + var priorLoginDate = user.lastLoginDate; + if (!priorLoginDate) { + priorLoginDate = new Date(); + } // Update priorLoginDate and lastLoginDate - Meteor.users.update({_id: Meteor.userId()}, {$set: {priorLoginDate: user.lastLoginDate, lastLoginDate: new Date()}}); + Meteor.users.update({_id: Meteor.userId()}, {$set: {priorLoginDate: priorLoginDate, lastLoginDate: new Date()}}); }, isAccountInactive: function (inactivityParameters) {