Separado aclService en fichero propio
This commit is contained in:
parent
81f9de098d
commit
fd3dd56542
|
@ -0,0 +1,28 @@
|
|||
import ngModule from './module';
|
||||
|
||||
function aclService() {
|
||||
this.roles = window.Salix.acl.roles;
|
||||
this.routeHasPermission = function(route) {
|
||||
let hasPermission;
|
||||
if (!route.acl)
|
||||
hasPermission = true;
|
||||
else if (!this.roles || !Object.keys(this.roles).length)
|
||||
hasPermission = false;
|
||||
else
|
||||
hasPermission = this.aclPermission(route.acl);
|
||||
return hasPermission;
|
||||
};
|
||||
this.aclPermission = function(aclCollection) {
|
||||
let hasPermission = false;
|
||||
let total = aclCollection.length;
|
||||
for (let i = 0; i < total; i++) {
|
||||
if (this.roles[aclCollection[i]]) {
|
||||
hasPermission = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasPermission;
|
||||
};
|
||||
}
|
||||
|
||||
ngModule.service('aclService', aclService);
|
|
@ -1,5 +1,6 @@
|
|||
import './module';
|
||||
import './spliting';
|
||||
import './aclService';
|
||||
import './configroutes';
|
||||
import './config';
|
||||
import './run';
|
||||
|
|
|
@ -76,28 +76,4 @@ function interceptorConfig($httpProvider) {
|
|||
}
|
||||
ngModule.config(interceptorConfig);
|
||||
|
||||
function aclService() {
|
||||
this.roles = window.Salix.acl.roles;
|
||||
this.routeHasPermission = function(route) {
|
||||
let hasPermission;
|
||||
if (!route.acl)
|
||||
hasPermission = true;
|
||||
else if (!this.roles || !Object.keys(this.roles).length)
|
||||
hasPermission = false;
|
||||
else
|
||||
hasPermission = this.aclPermission(route.acl);
|
||||
return hasPermission;
|
||||
};
|
||||
this.aclPermission = function(aclCollection) {
|
||||
let hasPermission = false;
|
||||
let total = aclCollection.length;
|
||||
for (let i = 0; i < total; i++) {
|
||||
if (this.roles[aclCollection[i]]) {
|
||||
hasPermission = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasPermission;
|
||||
};
|
||||
}
|
||||
ngModule.service('aclService', aclService);
|
||||
|
||||
|
|
Loading…
Reference in New Issue