methods to use en the angular service

This commit is contained in:
Pau 2022-12-27 09:05:50 +01:00
parent 93de49eb98
commit 487c687666
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,29 @@
module.exports = Self => {
Self.remoteMethod('userAcl', {
description: 'Get all of the current user permissions',
accepts: [
{
arg: 'ctx',
type: 'Object',
http: {source: 'context'}
}
],
returns: {
type: 'Object',
root: true
},
http: {
path: '/user/acl',
verb: 'GET'
}
});
Self.userAcl = async function(ctx) {
let userId = ctx.req.accessToken.userId;
let models = Self.app.models;
let user = await models.User.findById(userId, {
fields: ['id', 'name', 'nickname']
});
};
};

View File

@ -3,11 +3,25 @@ import ngModule from '../module';
class UserAclService {
constructor($http) {
this.$http = $http;
this.roles = [];
}
reset() {
this.user = null;
this.roles = null;
}
load() {
// return this.$http.get
}
hasAny(roles) {
if (this.roles) {
for (let role of roles) {
if (this.roles[role])
return true;
}
}
return false;
}
}
UserAclService.$inject = ['$http'];