Compare commits

...

21 Commits

Author SHA1 Message Date
Javier Segarra 703e16ffcd Merge pull request '#6434 - signIn_issue' (!1892) from 6434-signIn_issue into dev
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #1892
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
2023-12-22 09:36:29 +00:00
Javier Segarra ec1befcfb0 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head This commit looks good Details
2023-12-22 09:25:57 +00:00
Javier Segarra dc661f298b refs #6434 test: update tests
gitea/salix/pipeline/head This commit looks good Details
2023-12-21 09:10:18 +00:00
Javier Segarra 0feb8e5a16 Merge branch '6434-signIn_issue' of https://gitea.verdnatura.es/verdnatura/salix into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-21 09:01:07 +01:00
Javier Segarra daef9ee59a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6434-signIn_issue 2023-12-21 09:01:02 +01:00
Javier Segarra 3c8ff346e2 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-21 06:58:09 +00:00
Javier Segarra 748d4724b5 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-20 13:29:29 +00:00
Javier Segarra cb35c36328 refs #6434 test: update tests
gitea/salix/pipeline/head This commit looks good Details
2023-12-20 10:59:36 +00:00
Javier Segarra 57b3d96628 refs #6434 fix: bad throw error
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-20 09:27:25 +00:00
Javier Segarra c3b91e1719 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-20 09:25:15 +00:00
Javier Segarra 5151cdca48 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-19 07:06:36 +00:00
Javier Segarra 8a66391cd5 Merge branch 'dev' into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:31:53 +00:00
Javier Segarra 11b54d66af refs #6434 fix: bad merge
gitea/salix/pipeline/head Build queued... Details
2023-12-13 13:31:32 +01:00
Javier Segarra 5a36fabf05 refs #6434 feat: insert record just when fail
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:07:57 +01:00
Javier Segarra 6af99b7669 refs #6434 feat: delete records whe !owner 2023-12-13 12:07:41 +01:00
Javier Segarra 5f93b8c440 refs #6434 fix: bad merge
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 12:01:18 +01:00
Javier Segarra 5b3645a641 refs #6434 fix: bad merge
gitea/salix/pipeline/head Build queued... Details
2023-12-13 11:59:00 +01:00
Javier Segarra d69b59b63e Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6434-signIn_issue
gitea/salix/pipeline/head There was a failure building this commit Details
2023-12-13 11:54:28 +01:00
Javier Segarra add3a81032 refs #6434 feat: remove recursively fn
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-15 09:29:26 +01:00
Javier Segarra 7f82243ce6 refs #6434 feat: create signInLog table
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-14 15:00:03 +01:00
Javier Segarra 5c777c705f refs #6434 feat: add new error message
gitea/salix/pipeline/head There was a failure building this commit Details
2023-11-14 13:00:20 +01:00
4 changed files with 16 additions and 15 deletions

View File

@ -27,8 +27,10 @@ describe('Renew Token', () => {
jasmine.clock().uninstall(); jasmine.clock().uninstall();
}); });
it('should renew process', async() => { it('should renew token', async() => {
jasmine.clock().mockDate(new Date(startingTime + 21600000)); const mockDate = new Date(startingTime + 26600000);
jasmine.clock().mockDate(mockDate);
console.log(startingTime, mockDate)
const {id} = await models.VnUser.renewToken(ctx); const {id} = await models.VnUser.renewToken(ctx);
expect(id).not.toEqual(ctx.req.accessToken.id); expect(id).not.toEqual(ctx.req.accessToken.id);

View File

@ -20,10 +20,7 @@ describe('VnUser Sign-in()', () => {
let ctx = {req: {accessToken: accessToken}}; let ctx = {req: {accessToken: accessToken}};
let signInLog = await SignInLog.find({where: {token: accessToken.id}}); let signInLog = await SignInLog.find({where: {token: accessToken.id}});
expect(signInLog.length).toEqual(1); expect(signInLog.length).toEqual(0);
expect(signInLog[0].userFk).toEqual(accessToken.userId);
expect(signInLog[0].owner).toEqual(true);
expect(login.token).toBeDefined();
await VnUser.logout(ctx.req.accessToken.id); await VnUser.logout(ctx.req.accessToken.id);
}); });

View File

@ -134,15 +134,16 @@ module.exports = function(Self) {
Self.signInValidate = async(user, userToken, token, ctx) => { Self.signInValidate = async(user, userToken, token, ctx) => {
const [[key, value]] = Object.entries(Self.userUses(user)); const [[key, value]] = Object.entries(Self.userUses(user));
const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]); const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]);
await Self.app.models.SignInLog.create({ if (!isOwner) {
userName: user, await Self.app.models.SignInLog.create({
token: token.id, userName: user,
userFk: userToken.id, token: token.id,
ip: ctx.req.ip, userFk: userToken.id,
owner: isOwner ip: ctx.req.ip,
}); owner: isOwner
if (!isOwner) });
throw new UserError('Try again'); throw new UserError('Try again');
}
}; };
/** /**

View File

@ -0,0 +1 @@
DELETE FROM `account`.`signInLog` where owner <> FALSE