#6276 createNewWarehouse methods migrated from silex to salix #1850
|
@ -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
I en ningun cas es
opts.httpCtx.active?.accessToken?.userId
?En el archivo loopback>common>mixins>loggable, se ha aplicado cambios para recoger directamente el userId. Cambio realizado por Juan.