From 430f85cc59ec8cbd229748d678c6da0f2de337eb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 4 Dec 2013 14:01:31 +0100 Subject: LDAP Wizard: avoid a manually deactivated LDAP configuration is enabled by just opening the admin page --- apps/user_ldap/js/settings.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'apps/user_ldap/js/settings.js') diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 5b5f2030635..801de12ea94 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -489,13 +489,17 @@ var LdapWizard = { loginfilter = $('#ldap_login_filter').val(); //FIXME: activates a manually deactivated configuration. - if(host && port && base && userfilter && loginfilter) { + if(host && port && base && userfilter && loginfilter) { LdapWizard.updateStatusIndicator(true); if($('#ldap_configuration_active').is(':checked')) { return; } - $('#ldap_configuration_active').prop('checked', true); - LdapWizard.save($('#ldap_configuration_active')[0]); + if(!LdapWizard.isConfigurationActiveControlLocked) { + //avoids a manually deactivated connection will be activated + //upon opening the admin page + $('#ldap_configuration_active').prop('checked', true); + LdapWizard.save($('#ldap_configuration_active')[0]); + } } else { if($('#ldap_configuration_active').is(':checked')) { $('#ldap_configuration_active').prop('checked', false); @@ -517,9 +521,12 @@ var LdapWizard = { $(id + " + button").css('display', 'inline'); }, + isConfigurationActiveControlLocked: true, + init: function() { LdapWizard.basicStatusCheck(); LdapWizard.functionalityCheck(); + LdapWizard.isConfigurationActiveControlLocked = false; }, initGroupFilter: function() { -- cgit v1.2.3 From 06577f1fe2d3a164b188cf303b0077f6b54b9f57 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 3 Dec 2013 13:27:45 +0100 Subject: LDAP Wizard: make sure auto-detected suggestions are really applied initially. Also make initial filter compilation and user counting robust against race conditions. --- apps/user_ldap/js/settings.js | 57 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'apps/user_ldap/js/settings.js') diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 801de12ea94..a6bfa7549fe 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -407,6 +407,7 @@ var LdapWizard = { if($('#rawLoginFilterContainer').hasClass('invisible')) { $('#ldap_loginfilter_attributes').multiselect('enable'); } + LdapWizard.postInitLoginFilter(); }, function (result) { //deactivate if no attributes found @@ -443,10 +444,24 @@ var LdapWizard = { //enable only when raw filter editing is not turned on $('#'+multisel).multiselect('enable'); } + if(type == 'Users') { + //required for initial save + filter = $('#ldap_userlist_filter').val(); + if(!filter) { + LdapWizard.saveMultiSelect(multisel, + $('#'+multisel).multiselect("getChecked")); + } + LdapWizard.userFilterAvailableGroupsHasRun = true; + LdapWizard.postInitUserFilter(); + } }, function (result) { LdapWizard.hideSpinner('#'+multisel); $('#'+multisel).multiselect('disable'); + if(type == 'Users') { + LdapWizard.userFilterAvailableGroupsHasRun = true; + LdapWizard.postInitUserFilter(); + } } ); }, @@ -471,9 +486,23 @@ var LdapWizard = { LdapWizard.hideSpinner('#'+multisel); LdapWizard.applyChanges(result); $('#'+multisel).multiselect('refresh'); + if(type == 'User') { + //required for initial save + filter = $('#ldap_userlist_filter').val(); + if(!filter) { + LdapWizard.saveMultiSelect(multisel, + $('#'+multisel).multiselect("getChecked")); + } + LdapWizard.userFilterObjectClassesHasRun = true; + LdapWizard.postInitUserFilter(); + } }, function (result) { LdapWizard.hideSpinner('#'+multisel); + if(type == 'User') { + LdapWizard.userFilterObjectClassesHasRun = true; + LdapWizard.postInitUserFilter(); + } //TODO: error handling } ); @@ -536,11 +565,19 @@ var LdapWizard = { LdapWizard.countGroups(); }, + /** init login filter tab section **/ + initLoginFilter: function() { LdapWizard.regardFilterMode('Login'); LdapWizard.findAttributes(); }, + postInitLoginFilter: function() { + LdapWizard.composeFilter('login'); + }, + + /** end of init user filter tab section **/ + initMultiSelect: function(object, id, caption) { object.multiselect({ header: false, @@ -553,13 +590,29 @@ var LdapWizard = { }); }, + /** init user filter tab section **/ + + userFilterObjectClassesHasRun: false, + userFilterAvailableGroupsHasRun: false, + initUserFilter: function() { + LdapWizard.userFilterObjectClassesHasRun = false; + LdapWizard.userFilterAvailableGroupsHasRun = false; LdapWizard.regardFilterMode('User'); LdapWizard.findObjectClasses('ldap_userfilter_objectclass', 'User'); LdapWizard.findAvailableGroups('ldap_userfilter_groups', 'Users'); - LdapWizard.countUsers(); }, + postInitUserFilter: function() { + if(LdapWizard.userFilterObjectClassesHasRun + && LdapWizard.userFilterAvailableGroupsHasRun) { + LdapWizard.composeFilter('user'); + LdapWizard.countUsers(); + } + }, + + /** end of init user filter tab section **/ + onTabChange: function(event, ui) { newTabIndex = 0; if(ui.newTab[0].id === '#ldapWizard2') { @@ -626,8 +679,6 @@ var LdapWizard = { } else if(mode == LdapWizard.filterModeAssisted && !$('#raw'+subject+'FilterContainer').hasClass('invisible')) { LdapWizard['toggleRaw'+subject+'Filter'](); - } else { - c = $('#raw'+subject+'FilterContainer').hasClass('invisible'); } }, function (result) { -- cgit v1.2.3 From 60b1191c889baeaa408e6e923da4f630bbecb3ff Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 3 Dec 2013 20:45:05 +0100 Subject: some equals are more equal than other equals --- apps/user_ldap/js/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/user_ldap/js/settings.js') diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index a6bfa7549fe..b87590d9754 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -444,7 +444,7 @@ var LdapWizard = { //enable only when raw filter editing is not turned on $('#'+multisel).multiselect('enable'); } - if(type == 'Users') { + if(type === 'Users') { //required for initial save filter = $('#ldap_userlist_filter').val(); if(!filter) { @@ -486,7 +486,7 @@ var LdapWizard = { LdapWizard.hideSpinner('#'+multisel); LdapWizard.applyChanges(result); $('#'+multisel).multiselect('refresh'); - if(type == 'User') { + if(type === 'User') { //required for initial save filter = $('#ldap_userlist_filter').val(); if(!filter) { -- cgit v1.2.3 From 3480766a78e61d58fea4fd01336558d5562e0576 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 3 Dec 2013 20:50:46 +0100 Subject: LDAP Wizard: don't generate filter when not allowed --- apps/user_ldap/js/settings.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/user_ldap/js/settings.js') diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index b87590d9754..acf88ef58a4 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -573,7 +573,9 @@ var LdapWizard = { }, postInitLoginFilter: function() { - LdapWizard.composeFilter('login'); + if($('#rawLoginFilterContainer').hasClass('invisible')) { + LdapWizard.composeFilter('login'); + } }, /** end of init user filter tab section **/ -- cgit v1.2.3