refs #5036 removed grabUserLog function
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-03-10 10:02:34 +01:00
parent 9ff920c67e
commit e66974f77f
1 changed files with 6 additions and 14 deletions

View File

@ -328,8 +328,11 @@ class VnMySQL extends MySQL {
// Fetch old values (update|delete) or login
let where, id, data, idName, limit, op, oldInstances, newInstances;
const hasGrabUser = settings.log && settings.log.grabUser;
if(hasGrabUser)
await this.grabUserLog(Model, opts, 'login');
if(hasGrabUser){
const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId;
const user = await Model.app.models.Account.findById(userId, {fields: ['name']}, opts);
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
}
else {
where = ctx.where;
id = ctx.id;
@ -363,7 +366,7 @@ class VnMySQL extends MySQL {
});
if(hasGrabUser)
await this.grabUserLog(Model, opts, 'logout');
await this.executeP(`CALL account.myUser_logout()`, null, opts);
else {
// Fetch new values
const ids = [];
@ -402,17 +405,6 @@ class VnMySQL extends MySQL {
}
}
async grabUserLog(Model, opts, action) {
if(action == 'login'){
const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId;
const user = await Model.app.models.Account.findById(userId, {fields: ['name']}, opts);
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
}
else if(action == 'logout')
await this.executeP(`CALL account.myUser_logout()`, null, opts);
}
buildSelectStmt(op, data, idName, model, where, limit) {
const Model = this.getModelDefinition(model).model;
const properties = Object.keys(Model.definition.properties);