mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added populate last login time
closes #2515 - sets last_login when user is saved if user status changed to active - added integration test in user Basic Operations
This commit is contained in:
parent
a458165cf0
commit
f8d90f1cc6
2 changed files with 10 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
Loading…
Reference in a new issue