From e0b33fddf71dd2016b9bfd56f630afe4bdf44fbf Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Mon, 28 Sep 2026 09:38:24 +0200 Subject: [PATCH] Fix: sync mail login with OAuth authorization on load --- CHANGELOG.md | 1 + inc/mailcollectorfeature.class.php | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d06c960..5f97448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Restore missing include in ajax/dropdownAuthorization.php +- Fix mail collector login field not synced with the selected OAuth authorization on form load ## [1.4.5] - 2026-06-24 diff --git a/inc/mailcollectorfeature.class.php b/inc/mailcollectorfeature.class.php index 585bf0d..f2755df 100644 --- a/inc/mailcollectorfeature.class.php +++ b/inc/mailcollectorfeature.class.php @@ -145,6 +145,17 @@ function () { login_field.parent().append('
'); var auth_field_container = $('#auth_field_container'); + // Sync login field value onto the value carried by the authorization select + // (dropdown option selected by the user, or the one pre-selected on load). + var sync_login_from_auth_select = function () { + var select = auth_field_container.find('select'); + if (select.val() == -1) { + login_field.val(''); + } else { + login_field.val(select.find('option:selected').text()); + } + }; + server_type_field.on( 'change', function (evt) { @@ -161,7 +172,8 @@ function (evt) { { application_id: application_id, selected: login_field.val() - } + }, + sync_login_from_auth_select ); } else { password_field.closest('tr').show(); @@ -177,13 +189,7 @@ function (evt) { auth_field_container.on( 'change', 'select', - function (evt) { - if ($(this).val() == -1) { - login_field.val(''); - } else { - login_field.val($(this).find('option:selected').text()); - } - } + sync_login_from_auth_select ); server_type_field.trigger('change');