From 14489518d76b5e0ced3213e09f2143140b234674 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 1 Jun 2022 14:00:53 +0200 Subject: [PATCH] fixes testing meta data before applying settings - when a setting is changed() fetching the meta data is run first, before storing the value - it may appear that a breaking change is good, or - vice versa that a, actual fixing change does not have effect Signed-off-by: Arthur Schiwon --- js/admin.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/js/admin.js b/js/admin.js index 57f1eb9..e87c3b0 100644 --- a/js/admin.js +++ b/js/admin.js @@ -127,6 +127,23 @@ } }, + testMetaData: function() { + // Checks on each request whether the settings make sense or not + $.ajax({ + url: OC.generateUrl('/apps/user_saml/saml/metadata'), + data: { idp: OCA.User_SAML.Admin.getConfigIdentifier() }, + type: 'GET' + }).fail(function (e) { + if (e.status === 500) { + $('#user-saml-settings-complete').addClass('hidden'); + $('#user-saml-settings-incomplete').removeClass('hidden'); + } + }).success(function () { + $('#user-saml-settings-complete').removeClass('hidden'); + $('#user-saml-settings-incomplete').addClass('hidden'); + }); + }, + setSamlConfigValue: function(category, setting, value, global) { if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.setSamlConfigValue, this, category, setting, value)); @@ -137,6 +154,7 @@ var callbacks = { success: function () { OC.msg.finishedSaving('#user-saml-save-indicator', {status: 'success', data: {message: t('user_saml', 'Saved')}}); + OCA.User_SAML.Admin.testMetaData(); }, error: function() { OC.msg.finishedSaving('#user-saml-save-indicator', {status: 'error', data: {message: t('user_saml', 'Could not save')}}); @@ -394,25 +412,6 @@ $(function() { } }); - $('#user-saml').change(function() { - if(type === 'saml') { - // Checks on each request whether the settings make sense or not - $.ajax({ - url: OC.generateUrl('/apps/user_saml/saml/metadata'), - data: { idp: OCA.User_SAML.Admin.getConfigIdentifier() }, - type: 'GET' - }).fail(function (e) { - if (e.status === 500) { - $('#user-saml-settings-complete').addClass('hidden'); - $('#user-saml-settings-incomplete').removeClass('hidden'); - } - }).success(function (e) { - $('#user-saml-settings-complete').removeClass('hidden'); - $('#user-saml-settings-incomplete').addClass('hidden'); - }) - } - }); - $('#user-saml-settings .toggle').on('click', function() { var el = $(this), nextSibling = el.parent().next(),