Enable permission check according to the new permissions

revert-dabc3590
kamidu 8 years ago
parent eea91960b7
commit 41d2856e39

@ -19,7 +19,6 @@
{{unit "cdmf.unit.lib.qrcode"}} {{unit "cdmf.unit.lib.qrcode"}}
{{unit "mdm.unit.device.qr-modal"}} {{unit "mdm.unit.device.qr-modal"}}
{{#zone "content"}} {{#zone "content"}}
{{#if permissions.VIEW_DASHBOARD}}
{{#if permissions.LIST_DEVICES}} {{#if permissions.LIST_DEVICES}}
<div class="row "> <div class="row ">
<div class="col-md-3 wr-stats-board"> <div class="col-md-3 wr-stats-board">
@ -151,9 +150,6 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{else}}
Permission denied
{{/if}}
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
{{js "js/dashboard.js"}} {{js "js/dashboard.js"}}

@ -20,10 +20,16 @@ function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var generalConfig = context.app.conf["generalConfig"]; var generalConfig = context.app.conf["generalConfig"];
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var viewModel = {}; var viewModel = {};
viewModel.permissions = userModule.getUIPermissions(); var permissions = {};
new Log().debug("## Permissions : " + stringify(userModule.getUIPermissions())); permissions.LIST_DEVICES = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/view");
permissions.LIST_POLICIES = userModule.isAuthorized("/permission/admin/device-mgt/policies/view");
permissions.LIST_ROLES = userModule.isAuthorized("/permission/admin/device-mgt/roles/view");
permissions.LIST_USERS = userModule.isAuthorized("/permission/admin/device-mgt/users/view");
permissions.ADD_POLICY = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage");
permissions.ADD_ROLE = userModule.isAuthorized("/permission/admin/device-mgt/roles/manage");
permissions.ADD_USER = userModule.isAuthorized("/permission/admin/device-mgt/users/manage");
viewModel.permissions = permissions;
//TODO: Move enrollment URL into app-conf.json //TODO: Move enrollment URL into app-conf.json
viewModel.enrollmentURL = mdmProps.generalConfig.host + mdmProps.enrollmentDir; viewModel.enrollmentURL = mdmProps.generalConfig.host + mdmProps.enrollmentDir;
return viewModel; return viewModel;

@ -22,23 +22,14 @@
{{/zone}} {{/zone}}
{{#zone "navMenu-items"}} {{#zone "navMenu-items"}}
{{#if permissions.VIEW_DASHBOARD}}
<li> <li>
<a href="{{@app.context}}"> <a href="{{@app.context}}">
<i class="fw fw-dashboard"></i> <i class="fw fw-dashboard"></i>
Admin Dashboard Admin Dashboard
</a> </a>
</li> </li>
{{/if}}
{{#if permissions.LIST_DEVICES_ADMIN}} {{#if permissions.LIST_DEVICES}}
<li>
<a href="{{@app.context}}/devices">
<i class="fw fw-mobile"></i>
Device Management
</a>
</li>
{{else}}
{{#if permissions.LIST_OWN_DEVICES}}
<li> <li>
<a href="{{@app.context}}/devices"> <a href="{{@app.context}}/devices">
<i class="fw fw-mobile"></i> <i class="fw fw-mobile"></i>
@ -46,7 +37,6 @@
</a> </a>
</li> </li>
{{/if}} {{/if}}
{{/if}}
<li><a><i class="fw fw-user"></i>User Management</a> <li><a><i class="fw fw-user"></i>User Management</a>
<ul> <ul>
@ -64,12 +54,12 @@
{{/if}} {{/if}}
<li><a><i class="fw fw-settings"></i>Configuration Management</a> <li><a><i class="fw fw-settings"></i>Configuration Management</a>
<ul> <ul>
{{#if permissions.TENANT_CONFIGURATION}} {{#if permissions.LIST_CONFIGURATION}}
<li><a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>Platform Configurations</a> <li><a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>Platform Configurations</a>
</li> </li>
{{/if}} {{/if}}
<!-- todo change the permission and get the related permission --> <!-- todo change the permission and get the related permission -->
{{#if permissions.TENANT_CONFIGURATION}} {{#if permissions.LIST_CONFIGURATION}}
<li><a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>Certificate Configurations</a> <li><a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>Certificate Configurations</a>
</li> </li>
{{/if}} {{/if}}
@ -93,7 +83,7 @@
</ul> </ul>
{{/zone}} {{/zone}}
{{#zone "sidePanes"}} {{#zone "sidePanes"}}
<div class="sidebar-wrapper" id="right-sidebar" is-authorized="{{isAuthorizedForNotifications}}" <div class="sidebar-wrapper" id="right-sidebar" is-authorized="{{permissions.LIST_NOTIFICATIONS}}"
data-side="right" data-width="320" data-sidebar-fixed="true" data-fixed-offset="50" data-spy="affix" data-side="right" data-width="320" data-sidebar-fixed="true" data-fixed-offset="50" data-spy="affix"
data-offset-top="80"> data-offset-top="80">
<ul class="sidebar-messages"> <ul class="sidebar-messages">

@ -30,27 +30,30 @@ function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
var uiPermissions = userModule.getUIPermissions();
context["permissions"] = uiPermissions;
var links = { var links = {
"user-mgt": [], "user-mgt": [],
"role-mgt": [], "role-mgt": [],
"policy-mgt": [], "policy-mgt": [],
"device-mgt": [] "device-mgt": []
}; };
var viewModel = {};
// following context.link value comes here based on the value passed at the point // following viewModel.link value comes here based on the value passed at the point
// where units are attached to a page zone. // where units are attached to a page zone.
// eg: {{unit "appbar" pageLink="users" title="User Management"}} // eg: {{unit "appbar" pageLink="users" title="User Management"}}
context["currentActions"] = links[context["pageLink"]]; viewModel["currentActions"] = links[viewModel["pageLink"]];
context["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"]; viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"];
var isAuthorizedForNotifications =
userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/view");
var currentUser = session.get(constants["USER_SESSION_KEY"]); var currentUser = session.get(constants["USER_SESSION_KEY"]);
context["isAuthorizedForNotifications"] = isAuthorizedForNotifications; var permissions = {};
context["currentUser"] = currentUser; permissions.LIST_DEVICES = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/view");
context["appContext"] = mdmProps["appContext"]; permissions.LIST_POLICIES = userModule.isAuthorized("/permission/admin/device-mgt/policies/view");
permissions.LIST_ROLES = userModule.isAuthorized("/permission/admin/device-mgt/roles/view");
permissions.LIST_USERS = userModule.isAuthorized("/permission/admin/device-mgt/users/view");
permissions.LIST_NOTIFICATIONS = userModule.isAuthorized("/permission/admin/device-mgt/notifications/view");
permissions.LIST_CONFIGURATION = userModule.isAuthorized("/permission/admin/device-mgt/configurations/view");
viewModel.permissions = permissions;
viewModel["currentUser"] = currentUser;
viewModel["appContext"] = mdmProps["appContext"];
return context; return viewModel;
} }
Loading…
Cancel
Save