fix: refs #6276 loggable & userId
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
2940c68516
commit
8ad69a62b9
|
@ -1,6 +1,7 @@
|
|||
const LoopBackContext = require('loopback-context');
|
||||
async function handleObserve(ctx) {
|
||||
ctx.options.httpCtx = LoopBackContext.getCurrentContext();
|
||||
const httpCtx = LoopBackContext.getCurrentContext();
|
||||
ctx.options.userId = httpCtx?.active?.accessToken?.userId;
|
||||
}
|
||||
module.exports = function(Self) {
|
||||
let Mixin = {
|
||||
|
|
|
@ -275,7 +275,7 @@ class VnMySQL extends MySQL {
|
|||
}
|
||||
|
||||
invokeMethod(method, args, model, ctx, opts, cb) {
|
||||
if (!this.isLoggable(model))
|
||||
if (!this.isLoggable(model) && !opts?.userId)
|
||||
return super[method].apply(this, args);
|
||||
|
||||
this.invokeMethodP(method, [...args], model, ctx, opts)
|
||||
|
@ -287,11 +287,11 @@ class VnMySQL extends MySQL {
|
|||
let tx;
|
||||
if (!opts.transaction) {
|
||||
tx = await Transaction.begin(this, {});
|
||||
opts = Object.assign({transaction: tx, httpCtx: opts.httpCtx}, opts);
|
||||
opts = Object.assign({transaction: tx}, opts);
|
||||
}
|
||||
|
||||
try {
|
||||
const userId = opts.httpCtx && opts.httpCtx.active?.accessToken?.userId;
|
||||
const {userId} = opts;
|
||||
if (userId) {
|
||||
const user = await Model.app.models.VnUser.findById(userId, {fields: ['name']}, opts);
|
||||
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
Self.updateTracking = async(ctx, saleFk, originalQuantity, code, isChecked, buyFk, isScanned = null, options) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
const myOptions = {userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
Loading…
Reference in New Issue