diff --git a/client/salix/src/aclService.js b/client/salix/src/aclService.js new file mode 100644 index 000000000..aeb8b0129 --- /dev/null +++ b/client/salix/src/aclService.js @@ -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); diff --git a/client/salix/src/app.js b/client/salix/src/app.js index 0f5d3edb5..8ec2c5df7 100644 --- a/client/salix/src/app.js +++ b/client/salix/src/app.js @@ -1,5 +1,6 @@ import './module'; import './spliting'; +import './aclService'; import './configroutes'; import './config'; import './run'; diff --git a/client/salix/src/components/app/app.js b/client/salix/src/components/app/app.js index 8e417a491..c20c448ee 100644 --- a/client/salix/src/components/app/app.js +++ b/client/salix/src/components/app/app.js @@ -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); +