From 10cd93824edea97f6623ba210c3c5f32c5b3b095 Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Tue, 5 Mar 2024 22:55:33 +0000 Subject: [PATCH] bug fix in saving configuration changes on manage applications page --- js/module.js | 7 +++++++ manageapplication.php | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/js/module.js b/js/module.js index 463c391..c464a8a 100644 --- a/js/module.js +++ b/js/module.js @@ -11,6 +11,8 @@ M.auth_oidc.init = function(Y, idptype_ms, authmethodsecret, authmethodcertifica var $clientprivatekeyfile = $("#id_clientprivatekeyfile"); var $clientcertfile = $("#id_clientcertfile"); var $clientcertpassphrase = $("#id_clientcertpassphrase"); + var $clientcertsource = $("#id_clientcertsource"); + var $secretexpiryrecipients = $("#id_secretexpiryrecipients"); $idptype.change(function() { if ($(this).val() != idptype_ms) { @@ -19,11 +21,13 @@ M.auth_oidc.init = function(Y, idptype_ms, authmethodsecret, authmethodcertifica }); $clientauthmethod.val(authmethodsecret); $clientsecret.prop('disabled', false); + $clientcertsource.prop('disabled', true); $clientcert.prop('disabled', true); $clientprivatekey.prop('disabled', true); $clientprivatekeyfile.prop('disabled', true); $clientcertfile.prop('disabled', true); $clientcertpassphrase.prop('disabled', true); + $secretexpiryrecipients.prop('disabled', false); } else { $clientauthmethod.append(""); } @@ -36,6 +40,9 @@ M.auth_oidc.init = function(Y, idptype_ms, authmethodsecret, authmethodcertifica $clientprivatekeyfile.prop('disabled', false); $clientcertfile.prop('disabled', false); $clientcertpassphrase.prop('disabled', false); + $clientcertsource.prop('disabled', false); + } else { + $secretexpiryrecipients.prop('disabled', false); } }); }; diff --git a/manageapplication.php b/manageapplication.php index 29fc6ec..ab6796b 100644 --- a/manageapplication.php +++ b/manageapplication.php @@ -57,7 +57,7 @@ $form = new application(null, ['oidcconfig' => $oidcconfig]); $formdata = []; foreach (['idptype', 'clientid', 'clientauthmethod', 'clientsecret', 'clientprivatekey', 'clientcert', 'clientcertsource', 'clientprivatekeyfile', 'clientcertfile', 'clientcertpassphrase', - 'authendpoint', 'tokenendpoint', 'oidcresource', 'oidcscope'] as $field) { + 'authendpoint', 'tokenendpoint', 'oidcresource', 'oidcscope', 'secretexpiryrecipients'] as $field) { if (isset($oidcconfig->$field)) { $formdata[$field] = $oidcconfig->$field; } @@ -81,6 +81,7 @@ if ($form->is_cancelled()) { switch ($fromform->clientauthmethod) { case AUTH_OIDC_AUTH_METHOD_SECRET: $configstosave[] = 'clientsecret'; + $configstosave[] = 'secretexpiryrecipients'; break; case AUTH_OIDC_AUTH_METHOD_CERTIFICATE: $configstosave[] = 'clientcertsource'; @@ -100,12 +101,16 @@ if ($form->is_cancelled()) { // Save config settings. $updateapplicationtokenrequired = false; + $settingschanged = false; foreach ($configstosave as $config) { $existingsetting = get_config('auth_oidc', $config); if ($fromform->$config != $existingsetting) { set_config($config, $fromform->$config, 'auth_oidc'); add_to_config_log($config, $existingsetting, $fromform->$config, 'auth_oidc'); - $updateapplicationtokenrequired = true; + $settingschanged = true; + if ($config != 'secretexpiryrecipients') { + $updateapplicationtokenrequired = true; + } } } @@ -130,6 +135,8 @@ if ($form->is_cancelled()) { } else { redirect($url, get_string('application_updated', 'auth_oidc')); } + } else if ($settingschanged) { + redirect($url, get_string('application_updated', 'auth_oidc')); } else { redirect($url, get_string('application_not_changed', 'auth_oidc')); }