0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Merge pull request #2516 from novaugust/last_login

Added populate last login time per #2515
This commit is contained in:
Hannah Wolfe 2014-04-05 19:50:36 +01:00
commit 395d7fd3e2
2 changed files with 10 additions and 1 deletions

View file

@ -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);

View file

@ -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];