From 1db1c2e7df97067fc192d21758163cb940afad9d Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 10 Mar 2019 11:12:44 +0100 Subject: [PATCH] Enabling LDAP working again LDAP/Github oauth and Google oauth no credentials/parameters are rejected now --- cps/admin.py | 41 ++++++++++++++++++++++++----------------- cps/static/js/main.js | 6 +++--- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/cps/admin.py b/cps/admin.py index 41273642..38a0d59e 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -385,7 +385,7 @@ def configuration_helper(origin): #LDAP configurator, if "config_login_type" in to_save and to_save["config_login_type"] == "1": - if "config_ldap_provider_url" not in to_save or "config_ldap_dn" not in to_save: + if to_save["config_ldap_provider_url"] == u'' or to_save["config_ldap_dn"] == u'': ub.session.commit() flash(_(u'Please enter a LDAP provider and a DN'), category="error") return render_title_template("config_edit.html", config=config, origin=origin, @@ -413,27 +413,34 @@ def configuration_helper(origin): # GitHub OAuth configuration if "config_login_type" in to_save and to_save["config_login_type"] == "2": - if "config_github_oauth_client_id" in to_save: - content.config_github_oauth_client_id = to_save["config_github_oauth_client_id"] - if "config_github_oauth_client_secret" in to_save: - content.config_github_oauth_client_secret = to_save["config_github_oauth_client_secret"] - - if content.config_github_oauth_client_id != config.config_github_oauth_client_id or \ - content.config_github_oauth_client_secret != config.config_github_oauth_client_secret: - reboot_required = True + if to_save["config_github_oauth_client_id"] == u'' or to_save["config_github_oauth_client_secret"] == u'': + ub.session.commit() + flash(_(u'Please enter Github oauth credentials'), category="error") + return render_title_template("config_edit.html", config=config, origin=origin, + gdriveError=gdriveError, feature_support=feature_support, + title=_(u"Basic Configuration"), page="config") + else: content.config_login_type = ub.LOGIN_OAUTH_GITHUB + content.config_github_oauth_client_id = to_save["config_github_oauth_client_id"] + content.config_github_oauth_client_secret = to_save["config_github_oauth_client_secret"] + reboot_required = True # Google OAuth configuration if "config_login_type" in to_save and to_save["config_login_type"] == "3": - if "config_google_oauth_client_id" in to_save: - content.config_google_oauth_client_id = to_save["config_google_oauth_client_id"] - if "config_google_oauth_client_secret" in to_save: - content.config_google_oauth_client_secret = to_save["config_google_oauth_client_secret"] - - if content.config_google_oauth_client_id != config.config_google_oauth_client_id or \ - content.config_google_oauth_client_secret != config.config_google_oauth_client_secret: - reboot_required = True + if to_save["config_google_oauth_client_id"] == u'' or to_save["config_google_oauth_client_secret"] == u'': + ub.session.commit() + flash(_(u'Please enter Google oauth credentials'), category="error") + return render_title_template("config_edit.html", config=config, origin=origin, + gdriveError=gdriveError, feature_support=feature_support, + title=_(u"Basic Configuration"), page="config") + else: content.config_login_type = ub.LOGIN_OAUTH_GOOGLE + content.config_google_oauth_client_id = to_save["config_google_oauth_client_id"] + content.config_google_oauth_client_secret = to_save["config_google_oauth_client_secret"] + reboot_required = True + + if "config_login_type" in to_save and to_save["config_login_type"] == "0": + content.config_login_type = ub.LOGIN_STANDARD if "config_log_level" in to_save: content.config_log_level = int(to_save["config_log_level"]) diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 1ed98266..6a59c6b7 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -34,7 +34,7 @@ $(document).on("change", "input[type=\"checkbox\"][data-control]", function () { $(document).on("change", "select[data-control]", function() { var $this = $(this); var name = $this.data("control"); - var showOrHide = $this.val(); + var showOrHide = parseInt($this.val()); // var showOrHideLast = $("#" + name + " option:last").val() for (var i = 0; i < $(this)[0].length; i++) { if (parseInt($(this)[0][i].value) === showOrHide) { @@ -230,12 +230,12 @@ $(function() { $(window).resize(function() { $(".discover .row").isotope("layout"); }); - + $(".author-expand").click(function() { $(this).parent().find("a.author-name").slice($(this).data("authors-max")).toggle(); $(this).parent().find("span.author-hidden-divider").toggle(); $(this).html() === $(this).data("collapse-caption") ? $(this).html("(...)") : $(this).html($(this).data("collapse-caption")); $(".discover .row").isotope("layout"); }); - + });