Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6274-loginWorkerTimeControl
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
89fda361bd
|
@ -27,8 +27,10 @@ describe('Renew Token', () => {
|
|||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('should renew process', async() => {
|
||||
jasmine.clock().mockDate(new Date(startingTime + 21600000));
|
||||
it('should renew token', async() => {
|
||||
const mockDate = new Date(startingTime + 26600000);
|
||||
jasmine.clock().mockDate(mockDate);
|
||||
console.log(startingTime, mockDate)
|
||||
const {id} = await models.VnUser.renewToken(ctx);
|
||||
|
||||
expect(id).not.toEqual(ctx.req.accessToken.id);
|
||||
|
|
|
@ -20,10 +20,7 @@ describe('VnUser Sign-in()', () => {
|
|||
let ctx = {req: {accessToken: accessToken}};
|
||||
let signInLog = await SignInLog.find({where: {token: accessToken.id}});
|
||||
|
||||
expect(signInLog.length).toEqual(1);
|
||||
expect(signInLog[0].userFk).toEqual(accessToken.userId);
|
||||
expect(signInLog[0].owner).toEqual(true);
|
||||
expect(login.token).toBeDefined();
|
||||
expect(signInLog.length).toEqual(0);
|
||||
|
||||
await VnUser.logout(ctx.req.accessToken.id);
|
||||
});
|
||||
|
|
|
@ -134,15 +134,16 @@ module.exports = function(Self) {
|
|||
Self.signInValidate = async(user, userToken, token, ctx) => {
|
||||
const [[key, value]] = Object.entries(Self.userUses(user));
|
||||
const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]);
|
||||
await Self.app.models.SignInLog.create({
|
||||
userName: user,
|
||||
token: token.id,
|
||||
userFk: userToken.id,
|
||||
ip: ctx.req.ip,
|
||||
owner: isOwner
|
||||
});
|
||||
if (!isOwner)
|
||||
throw new UserError('Try again');
|
||||
if (!isOwner) {
|
||||
await Self.app.models.SignInLog.create({
|
||||
userName: user,
|
||||
token: token.id,
|
||||
userFk: userToken.id,
|
||||
ip: ctx.req.ip,
|
||||
owner: isOwner
|
||||
});
|
||||
throw new UserError('Try again');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
DELETE FROM `account`.`signInLog` where owner <> FALSE
|
Loading…
Reference in New Issue