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

22 lines
595 B
JavaScript
Raw Normal View History

2018-10-05 11:01:46 +00:00
module.exports = function(Self) {
Self.remoteMethodCtx('getUserConfig', {
description: 'returns the information from UserConfig model for the active user',
accepts: [],
returns: {
arg: 'response',
type: 'object'
},
http: {
path: `/getUserConfig`,
verb: 'get'
}
});
Self.getUserConfig = async(ctx) => {
let token = ctx.req.accessToken;
let currentUserId = token && token.userId;
return await Self.app.models.UserConfig.findOne({userFk: currentUserId});
}
};