File tree 2 files changed +15
-2
lines changed
frontend/public/javascripts
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -250,13 +250,24 @@ var common = require('../../../api/utils/common.js'),
250
250
var apps = [ ] ;
251
251
if ( params . qstring . app_id ) {
252
252
//if app_id was provided, we need to check if user has access for this app_id
253
- if ( params . member . global_admin || ( params . member . user_of && params . member . user_of . indexOf ( params . qstring . app_id ) !== - 1 ) ) {
253
+ // is user_of array contain current app_id?
254
+ var isUserOf = params . member . user_of && params . member . user_of . indexOf ( params . qstring . app_id ) !== - 1 ;
255
+ var isRestricted = params . member . app_restrict && params . member . app_restrict [ params . qstring . app_id ] && params . member . app_restrict [ params . qstring . app_id ] . indexOf ( "#/manage/db" ) ;
256
+ if ( params . member . global_admin || isUserOf && ! isRestricted ) {
254
257
apps = [ params . qstring . app_id ] ;
255
258
}
256
259
}
257
260
else {
258
261
//use whatever user has permission for
259
262
apps = params . member . user_of || [ ] ;
263
+ // also check for app based restrictions
264
+ if ( params . member . app_restrict ) {
265
+ for ( var app_id in params . member . app_restrict ) {
266
+ if ( params . member . app_restrict [ app_id ] . indexOf ( "#/manage/db" ) !== - 1 && apps . indexOf ( app_id ) !== - 1 ) {
267
+ apps . splice ( apps . indexOf ( app_id ) , 1 ) ;
268
+ }
269
+ }
270
+ }
260
271
}
261
272
var appList = [ ] ;
262
273
if ( collection . indexOf ( "events" ) === 0 || collection . indexOf ( "drill_events" ) === 0 ) {
Original file line number Diff line number Diff line change @@ -83,7 +83,9 @@ window.DBViewerView = countlyView.extend({
83
83
$ ( '#app-list' ) . prepend ( '<div data-value="all" class="app-option item" data-localize=""><span class="app-title-in-dropdown">' + $ . i18n . map [ "common.all" ] + '</span></div>' ) ;
84
84
// append list items
85
85
for ( var key in countlyGlobal . apps ) {
86
- $ ( '#app-list' ) . append ( '<div data-value="' + countlyGlobal . apps [ key ] . _id + '" class="app-option item" data-localize=""><span class="app-title-in-dropdown">' + countlyGlobal . apps [ key ] . name + '</span></div>' ) ;
86
+ if ( ! countlyGlobal . member . app_restrict || ( countlyGlobal . member . app_restrict && ! countlyGlobal . member . app_restrict [ key ] ) ) {
87
+ $ ( '#app-list' ) . append ( '<div data-value="' + countlyGlobal . apps [ key ] . _id + '" class="app-option item" data-localize=""><span class="app-title-in-dropdown">' + countlyGlobal . apps [ key ] . name + '</span></div>' ) ;
88
+ }
87
89
}
88
90
// set height
89
91
if ( $ ( '#dbviewer' ) . height ( ) < ( window . innerHeight - 150 ) ) {
You can’t perform that action at this time.
0 commit comments