Added back route to be able to get user roles
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pau 2022-10-27 14:46:18 +02:00
parent 4334907d91
commit 2b05cb9655
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,31 @@
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;
};
};

View File

@ -8,6 +8,7 @@ module.exports = Self => {
require('../methods/account/set-password')(Self); require('../methods/account/set-password')(Self);
require('../methods/account/validate-token')(Self); require('../methods/account/validate-token')(Self);
require('../methods/account/privileges')(Self); require('../methods/account/privileges')(Self);
require('../methods/account/getRoles')(Self);
// Validations // Validations