mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🎨 change last_login to last_seen (#8259)
refs #8258 * 🎨 change last_login to last_seen - rename the column - a change in Ghost-Admin is required as well * test utils: revert export examples * revert line breaks
This commit is contained in:
parent
9b3c3943ef
commit
587ff6f026
8 changed files with 13 additions and 13 deletions
|
@ -47,7 +47,7 @@ module.exports = {
|
|||
meta_title: {type: 'string', maxlength: 2000, nullable: true},
|
||||
meta_description: {type: 'string', maxlength: 2000, nullable: true},
|
||||
tour: {type: 'text', maxlength: 65535, nullable: true},
|
||||
last_login: {type: 'dateTime', nullable: true},
|
||||
last_seen: {type: 'dateTime', nullable: true},
|
||||
created_at: {type: 'dateTime', nullable: false},
|
||||
created_by: {type: 'string', maxlength: 24, nullable: false},
|
||||
updated_at: {type: 'dateTime', nullable: true},
|
||||
|
|
|
@ -7,10 +7,10 @@ var config = require('../../config'),
|
|||
moment = require('moment-timezone');
|
||||
|
||||
/**
|
||||
* WHEN access token is created we will update last_login for user.
|
||||
* WHEN access token is created we will update last_seen for user.
|
||||
*/
|
||||
events.on('token.added', function (tokenModel) {
|
||||
models.User.edit({last_login: moment().toDate()}, {id: tokenModel.get('user_id')})
|
||||
models.User.edit({last_seen: moment().toDate()}, {id: tokenModel.get('user_id')})
|
||||
.catch(function (err) {
|
||||
logging.error(new errors.GhostError({err: err, level: 'critical'}));
|
||||
});
|
||||
|
|
|
@ -241,7 +241,7 @@ User = ghostBookshelf.Model.extend({
|
|||
}, {
|
||||
orderDefaultOptions: function orderDefaultOptions() {
|
||||
return {
|
||||
last_login: 'DESC',
|
||||
last_seen: 'DESC',
|
||||
name: 'ASC',
|
||||
created_at: 'DESC'
|
||||
};
|
||||
|
@ -364,7 +364,7 @@ User = ghostBookshelf.Model.extend({
|
|||
/**
|
||||
* ### Edit
|
||||
*
|
||||
* Note: In case of login the last_login attribute gets updated.
|
||||
* Note: In case of login the last_seen attribute gets updated.
|
||||
*
|
||||
* @extends ghostBookshelf.Model.edit to handle returning the full object
|
||||
* **See:** [ghostBookshelf.Model.edit](base.js.html#edit)
|
||||
|
@ -628,7 +628,7 @@ User = ghostBookshelf.Model.extend({
|
|||
|
||||
return self.isPasswordCorrect({plainPassword: object.password, hashedPassword: user.get('password')})
|
||||
.then(function then() {
|
||||
return Promise.resolve(user.set({status: 'active', last_login: new Date()}).save({validate: false}))
|
||||
return Promise.resolve(user.set({status: 'active', last_seen: new Date()}).save({validate: false}))
|
||||
.catch(function handleError(err) {
|
||||
// If we get a validation or other error during this save, catch it and log it, but don't
|
||||
// cause a login error because of it. The user validation is not important here.
|
||||
|
|
|
@ -92,11 +92,11 @@ describe('User API', function () {
|
|||
jsonResponse.users.should.have.length(4);
|
||||
|
||||
testUtils.API.checkResponse(jsonResponse.users[0], 'user');
|
||||
testUtils.API.isISO8601(jsonResponse.users[0].last_login).should.be.true();
|
||||
testUtils.API.isISO8601(jsonResponse.users[0].last_seen).should.be.true();
|
||||
testUtils.API.isISO8601(jsonResponse.users[0].created_at).should.be.true();
|
||||
testUtils.API.isISO8601(jsonResponse.users[0].updated_at).should.be.true();
|
||||
|
||||
testUtils.API.isISO8601(jsonResponse.users[2].last_login).should.be.true();
|
||||
testUtils.API.isISO8601(jsonResponse.users[2].last_seen).should.be.true();
|
||||
testUtils.API.isISO8601(jsonResponse.users[2].created_at).should.be.true();
|
||||
testUtils.API.isISO8601(jsonResponse.users[2].updated_at).should.be.true();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ describe('Users API', function () {
|
|||
}).then(function (response) {
|
||||
response.users[0].created_at.should.be.an.instanceof(Date);
|
||||
response.users[0].updated_at.should.be.an.instanceof(Date);
|
||||
response.users[0].last_login.should.be.an.instanceof(Date);
|
||||
response.users[0].last_seen.should.be.an.instanceof(Date);
|
||||
|
||||
done();
|
||||
}).catch(done);
|
||||
|
|
|
@ -184,7 +184,7 @@ describe('User Model', function run() {
|
|||
var userData = testUtils.DataGenerator.forModel.users[0];
|
||||
|
||||
UserModel.check({email: userData.email, password: userData.password}).then(function (activeUser) {
|
||||
should.exist(activeUser.get('last_login'));
|
||||
should.exist(activeUser.get('last_seen'));
|
||||
done();
|
||||
}).catch(done);
|
||||
});
|
||||
|
@ -201,7 +201,7 @@ describe('User Model', function run() {
|
|||
|
||||
should.exist(user);
|
||||
|
||||
lastLogin = user.get('last_login');
|
||||
lastLogin = user.get('last_seen');
|
||||
createdAt = user.get('created_at');
|
||||
updatedAt = user.get('updated_at');
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ var should = require('should'), // jshint ignore:line
|
|||
// both of which are required for migrations to work properly.
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
var currentSchemaHash = '8973f14e9a33601171dee3010d4cffd7',
|
||||
var currentSchemaHash = '461181eefd9a9171099093b67c59b90a',
|
||||
currentFixturesHash = 'ad12de59b939b13dc198611a6438ab51';
|
||||
|
||||
// If this test is failing, then it is likely a change has been made that requires a DB version bump,
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('Models: listeners', function () {
|
|||
|
||||
userModelSpy.calledOnce.should.be.true();
|
||||
userModelSpy.calledWith(
|
||||
sinon.match.has('last_login'),
|
||||
sinon.match.has('last_seen'),
|
||||
sinon.match.has('id')
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue