salix/services/loopback/common/methods/user-config/getUserConfig.js

22 lines
568 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: {
2018-10-08 06:14:25 +00:00
type: 'object',
root: true
2018-10-05 11:01:46 +00:00
},
http: {
path: `/getUserConfig`,
verb: 'get'
}
});
2018-10-08 06:14:25 +00:00
Self.getUserConfig = async ctx => {
2018-10-05 11:01:46 +00:00
let token = ctx.req.accessToken;
let currentUserId = token && token.userId;
2018-10-08 06:14:25 +00:00
return await Self.findOne({userFk: currentUserId});
};
2018-10-05 11:01:46 +00:00
};