32 lines
702 B
JavaScript
32 lines
702 B
JavaScript
module.exports = Self => {
|
|
Self.remoteMethodCtx('getUserRoles', {
|
|
description: 'Gets the user roles',
|
|
accepts:
|
|
{
|
|
arg: 'ctx',
|
|
type: 'Object',
|
|
http: {source: 'context'}
|
|
},
|
|
returns: {
|
|
type: 'object',
|
|
root: true
|
|
},
|
|
http: {
|
|
path: `/getUserRoles`,
|
|
verb: 'POST'
|
|
}
|
|
});
|
|
|
|
Self.getUserRoles = async ctx => {
|
|
// Get the user from the accesstoken
|
|
const userId = ctx.req.accessToken.userId;
|
|
|
|
// Get the user roles
|
|
const roles = await Self.getRoles(userId, {
|
|
ctx: ctx
|
|
});
|
|
|
|
return roles;
|
|
};
|
|
};
|