diff --git a/core/server/models/user.js b/core/server/models/user.js index 931447ec07..a77b826193 100644 --- a/core/server/models/user.js +++ b/core/server/models/user.js @@ -177,7 +177,7 @@ User = ghostBookshelf.Model.extend({ }); } - return when(user.set('status', 'active').save()).then(function (user) { + return when(user.set({status : 'active', last_login : new Date()}).save()).then(function (user) { return user; }); }, errors.logAndThrowError); diff --git a/core/test/integration/model/model_users_spec.js b/core/test/integration/model/model_users_spec.js index 8ce5652206..c85bec7101 100644 --- a/core/test/integration/model/model_users_spec.js +++ b/core/test/integration/model/model_users_spec.js @@ -141,6 +141,15 @@ describe('User Model', function run() { }, done); }); + it('sets last login time on successful login', function (done) { + var userData = testUtils.DataGenerator.forModel.users[0]; + + UserModel.check({email: userData.email, pw:userData.password}).then(function (activeUser) { + should.exist(activeUser.get('last_login')); + done(); + }).then(null, done); + }); + it('can\'t add second', function (done) { var userData = testUtils.DataGenerator.forModel.users[1];