salix/services/loopback/common/methods/userConfig/setUserConfig.js

29 lines
804 B
JavaScript

module.exports = function(Self) {
Self.remoteMethodCtx('setUserConfig', {
description: 'Change worker of tickets state',
accepts: [{
arg: 'params',
type: 'object',
required: true,
description: 'warehouseFk, companyFk',
http: {source: 'body'}
}],
returns: {
arg: 'response',
type: 'object'
},
http: {
path: `/setUserConfig`,
verb: 'post'
}
});
Self.setUserConfig = async(ctx, params) => {
let token = ctx.req.accessToken;
let currentUserId = token && token.userId;
params.userFk = currentUserId;
return await Self.app.models.UserConfig.upsertWithWhere({userFk: currentUserId}, params);
}
};