check permissions on client to hide/show careportal and boluscalc

This commit is contained in:
Jason Calabrese
2016-08-04 23:15:34 -07:00
parent 3937f8564f
commit 714ebd1540
2 changed files with 7 additions and 4 deletions
-2
View File
@@ -294,8 +294,6 @@ function init (client, plugins, $) {
data.relative = data.enteredinsulin * data.splitExt / 100 / data.duration * 60;
}
console.info('>>>client.authorized', client.authorized);
$.ajax({
method: 'POST'
, url: '/api/v1/treatments/'
+7 -2
View File
@@ -4,6 +4,7 @@
var _ = require('lodash');
var $ = (global && global.$) || require('jquery');
var d3 = (global && global.d3) || require('d3');
var shiroTrie = require('shiro-trie');
var language = require('../language')();
var sandbox = require('../sandbox')();
@@ -111,6 +112,7 @@ client.init = function init(serverSettings, plugins) {
if (serverSettings.authorized) {
client.authorized = serverSettings.authorized;
client.authorized.lat = Date.now();
client.authorized.shiro = shiroTrie.new(client.authorized.permissions);
}
client.headers = function headers ( ) {
@@ -876,8 +878,11 @@ client.init = function init(serverSettings, plugins) {
if (serverSettings.apiEnabled) {
$('.serverSettings').show();
}
$('#treatmentDrawerToggle').toggle(client.settings.showPlugins.indexOf('careportal') > -1);
$('#boluscalcDrawerToggle').toggle(client.settings.showPlugins.indexOf('boluscalc') > -1);
var treatmentCreateAllowed = client.authorized ? client.authorized.shiro.check('api:treatments:create') : client.hashauth.isAuthenticated;
$('#treatmentDrawerToggle').toggle(treatmentCreateAllowed && client.settings.showPlugins.indexOf('careportal') > -1);
$('#boluscalcDrawerToggle').toggle(treatmentCreateAllowed && client.settings.showPlugins.indexOf('boluscalc') > -1);
// hide food control if not enabled
$('.foodcontrol').toggle(client.settings.enable.indexOf('food') > -1);
// hide cob control if not enabled