diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 4ad71c950..5c1ceaa32 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -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);