From 49b6b069c19a390086ed52802263fa7db71cc3b2 Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Fri, 31 Jan 2025 14:07:03 +0930 Subject: [PATCH 1/2] add desiredRememberMeState to local storage --- .../mfa/prompt-for-mfa-backupcode.twig | 21 +++++++++++++++++-- .../material/mfa/prompt-for-mfa-manager.twig | 21 +++++++++++++++++-- .../material/mfa/prompt-for-mfa-totp.twig | 21 +++++++++++++++++-- .../material/mfa/prompt-for-mfa-webauthn.twig | 17 +++++++++++++-- 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig b/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig index e16ef2d6..646ac04d 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig @@ -4,6 +4,23 @@ {{ '{mfa:title}'|trans }} {{ include('header.twig') }} + +
@@ -74,11 +91,11 @@
-
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig b/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig index 74db6ec0..f85337e5 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig @@ -4,6 +4,23 @@ {{ '{mfa:title}'|trans }} {{ include('header.twig') }} + +
@@ -74,11 +91,11 @@
-
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig b/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig index 41bf21cc..2b72b19f 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig @@ -4,6 +4,23 @@ {{ '{mfa:title}'|trans }} {{ include('header.twig') }} + +
@@ -72,11 +89,11 @@
-
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig b/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig index 779b8ad8..cfee7729 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig @@ -9,6 +9,19 @@ +
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig b/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig index f85337e5..366950c4 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig @@ -5,22 +5,7 @@ {{ include('header.twig') }} - +
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig b/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig index 2b72b19f..47815d0c 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig @@ -5,22 +5,7 @@ {{ include('header.twig') }} - +
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig b/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig index cfee7729..3b714940 100644 --- a/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig +++ b/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig @@ -9,19 +9,6 @@ + + diff --git a/modules/mfa/public/prompt-for-mfa.php b/modules/mfa/public/prompt-for-mfa.php index 29530c7b..9d9038f3 100644 --- a/modules/mfa/public/prompt-for-mfa.php +++ b/modules/mfa/public/prompt-for-mfa.php @@ -125,6 +125,7 @@ $t->data['mfa_options'] = $mfaOptions; $browserJsHash = md5_file(__DIR__ . '/simplewebauthn/browser.js'); $t->data['browser_js_path'] = '/module.php/mfa/simplewebauthn/browser.js?v=' . $browserJsHash; +$t->data['remember_me_js_path'] = '/module.php/mfa/public/remember-me.js'; $t->data['manager_email'] = $state['managerEmail']; $t->data['other_options'] = $otherOptions; $t->data['idp_name'] = $t->getEntityDisplayName($state['IdPMetadata']); diff --git a/modules/mfa/public/remember-me.js b/modules/mfa/public/remember-me.js new file mode 100644 index 00000000..3683e3a8 --- /dev/null +++ b/modules/mfa/public/remember-me.js @@ -0,0 +1,14 @@ +document.addEventListener('DOMContentLoaded', function() { + const rememberMeCheckbox = document.getElementById('rememberMe'); + + if (rememberMeCheckbox) { + const desiredRememberMeState = localStorage.getItem('desiredRememberMeState'); + if (desiredRememberMeState === 'true') { + rememberMeCheckbox.checked = true; + } + + rememberMeCheckbox.addEventListener('change', function() { + localStorage.setItem('desiredRememberMeState', rememberMeCheckbox.checked); + }); + } +});