role based authorization

9 views
Skip to first unread message

Tito

unread,
May 14, 2018, 1:49:07 PM5/14/18
to Angular and AngularJS discussion
Greetings,

Still in AngularJS and I want to leverage role based navigation so that if user has certain roles they can see a route/screen. 
The following is the userRoles array coming back from my api. it uses the currently logeed in user's samaccountname (ldap) to grab their roles in a certain application

vm.userroles = []
{roleCode: "READ_WRITE", applicationcode: "MAP", rolename: "Read/Write"}
{roleCode: "WORKPLAN_RESERVE", applicationcode: "MAP", rolename: "Workplan Reserve"}


The following is the controller for workplan.html

function getUserRoles() {
return dataservice.getUserRoles().then(function (data) {
vm.userroles = data;
return vm.userroles;
});
}

My challenge is on the router part of this workplan.route.js. How do I feed it this data? Feels so close yet so far away. I know I am real close though :)

return [
{
state: 'workplan',
config: {
url: '/',
templateUrl: 'app/workplan/workplan.html',
controller: 'workplan',
controllerAs: 'vm',
data: {
roles: ['Admin']
},
title: 'Workplan',
settings: {
nav: 1,
content: '<i class="fa fa-cogs"></i> Workplan'
}


Reply all
Reply to author
Forward
0 new messages