From 96f9383178e169ce847364d84d835aee78346e8c Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Thu, 28 Sep 2023 17:07:05 +0100 Subject: [PATCH] Automatically unset system API user token if application access is enabled --- settings.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/settings.php b/settings.php index 2362e64f5..c266a045c 100644 --- a/settings.php +++ b/settings.php @@ -110,6 +110,12 @@ $desc = new lang_string('settings_setup_step2_desc', 'local_o365'); $systemapiuser = get_config('local_o365', 'systemtokens'); + $enableapponlyaccess = get_config('local_o365', 'enableapponlyaccess'); + if (!empty($enableapponlyaccess) && !empty($systemapiuser)) { + // Both "Application access" and "System API user" are enabled - we simply disable "System API user". + unset_config('systemtokens', 'local_o365'); + $systemapiuser = null; + } if (!empty($systemapiuser)) { // Show option to convert to app only access. $desc .= new lang_string('settings_setup_step2_desc_additional', 'local_o365');