From 80bd189eb492a35ed5d30b8acf77603f64613749 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Fri, 4 Nov 2022 11:18:41 +0100 Subject: clear remembered username/password when disabling remember --- .../asit/pdfover/gui/workflow/states/MobileBKUState.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java index 92dca222..e1ecf39c 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/MobileBKUState.java @@ -263,6 +263,19 @@ public class MobileBKUState extends State { return r; } + private void updateRememberPasswordSetting(boolean enabled, boolean allowEnabling) { + final var config = getStateMachine().configProvider; + if (enabled == config.getRememberMobilePassword()) /* nothing to do here */ + return; + if (enabled && !allowEnabling) /* do not allow "cancel" to set the remember checkbox */ + return; + config.setRememberMobilePasswordPersistent(enabled); + if (!enabled) { /* clear remembered info */ + config.setDefaultMobileNumberPersistent(null); + config.setDefaultMobilePasswordOverlay(null); + } + } + public void getCredentialsFromUserTo(@Nonnull UsernameAndPassword credentials, @Nullable String errorMessage) throws UserCancelledException { Display.getDefault().syncCall(() -> { MobileBKUEnterNumberComposite ui = this.getMobileBKUEnterNumberComposite(); @@ -292,8 +305,7 @@ public class MobileBKUState extends State { } } - if (!(ui.userCancel && ui.isRememberPassword())) /* don't allow "remember" to be enabled via cancel button */ - getStateMachine().configProvider.setRememberMobilePasswordPersistent(ui.isRememberPassword()); + updateRememberPasswordSetting(ui.isRememberPassword(), !ui.userCancel); if (ui.userCancel) { ui.userCancel = false; -- cgit v1.2.3