From 8af5788fc193a245c8aeed3b554a79baaa1bde3a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Mar 2023 17:29:56 +0000 Subject: [PATCH] more mfa cleanup, set the value in session if mfa is enabled and only allow enabling mfa after a test passed --- Zotlabs/Module/Settings/Multifactor.php | 8 +- view/tpl/settings_account.tpl | 1 + view/tpl/totp_setup.tpl | 177 ++++++++---------------- 3 files changed, 63 insertions(+), 123 deletions(-) diff --git a/Zotlabs/Module/Settings/Multifactor.php b/Zotlabs/Module/Settings/Multifactor.php index e1d8e1c97..5ac47be09 100644 --- a/Zotlabs/Module/Settings/Multifactor.php +++ b/Zotlabs/Module/Settings/Multifactor.php @@ -18,6 +18,9 @@ class Multifactor { } $enable_mfa = isset($_POST['enable_mfa']) ? (int) $_POST['enable_mfa'] : false; AConfig::Set($account['account_id'], 'system', 'mfa_enabled', $enable_mfa); + if ($enable_mfa) { + $_SESSION['2FA_VERIFIED'] = true; + } } public function get() { @@ -48,10 +51,11 @@ class Multifactor { return replace_macros(get_markup_template('totp_setup.tpl'), [ '$form_security_token' => get_form_security_token("settings_mfa"), - '$title' => t('Multifactor Settings'), + '$title' => t(' Account Multifactor Settings'), '$totp_setup_text' => t('Multi-Factor Authentication Setup'), - '$secret_text' => t('This is your generated secret. This may be used in some cases if the QR image cannot be read. Please save it.'), + '$secret_text' => t('This is your generated secret. It may be used in some cases if the QR image cannot be read. Please save it.'), '$test_title' => t('Please enter the code from your authenticator'), + '$test_title_sub' => t('You will only be able to enable MFA if the test passes'), '$qrcode' => (new QRCode())->render($uri), '$uri' => $uri, '$secret' => ($account['account_external'] ?? ''), diff --git a/view/tpl/settings_account.tpl b/view/tpl/settings_account.tpl index 2b942d694..b0076f380 100644 --- a/view/tpl/settings_account.tpl +++ b/view/tpl/settings_account.tpl @@ -17,6 +17,7 @@
+ Configure MFA
{{$account_settings}} diff --git a/view/tpl/totp_setup.tpl b/view/tpl/totp_setup.tpl index 6bf5885f7..4139e3552 100644 --- a/view/tpl/totp_setup.tpl +++ b/view/tpl/totp_setup.tpl @@ -1,130 +1,65 @@
-
-

{{$title}}

-
- -
- - {{if $secret}} -
-
{{$secret_text}}
-
-
{{$secret}}
-
- {{/if}} - - {{$uri}} - -
-
-
- -
-
- -
-
- -
-
-
- -
-
- - -
- - {{include file="field_checkbox.tpl" field=$enable_mfa}} -
- -
- -
- - -
- +
+

{{$title}}

+
+
+ {{if $secret}} + + {{/if}} + {{$uri}} +
+
+
+ + + {{$test_title_sub}} +
+ +
+ +
+
+
+
+
+ + {{include file="field_checkbox.tpl" field=$enable_mfa}} +
+ +
+
+
+
-