From 4980b54c0dc5fd8b2a26589dacfd583c4908e5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ou=C5=A1ek?= <brousek@ics.muni.cz> Date: Fri, 25 Mar 2022 08:48:51 +0100 Subject: [PATCH] fix: fix hiding of alternate methods --- templates/LoginForm.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/templates/LoginForm.php b/templates/LoginForm.php index e3083c6..93528e0 100644 --- a/templates/LoginForm.php +++ b/templates/LoginForm.php @@ -3,10 +3,15 @@ use SimpleSAML\Module; $this->data['u2fAvailable'] = !empty($this->data['u2fSignRequest']); -$this->data['webAuthnAvailable'] = !empty($this->data['webAuthnSignRequest']); -$this->data['noAlternatives'] = !$this->data['pushAvailable'] && (!$this->data['u2fAvailable']) && (!$this->data['webAuthnAvailable']); - +$this->data['webauthnAvailable'] = !empty($this->data['webAuthnSignRequest']); $this->data['mode'] = ($this->data['mode'] ?? null) ?: 'otp'; +$this->data['noAlternatives'] = true; +foreach (['otp', 'push', 'u2f', 'webauthn'] as $mode) { + if ($mode !== $this->data['mode'] && $this->data[$mode . 'Available']) { + $this->data['noAlternatives'] = false; + break; + } +} // Set default scenario if isn't set if (!empty($this->data['authProcFilterScenario'])) { @@ -259,7 +264,7 @@ if (null !== $this->data['errorCode']) { <div id="AlternateLoginOptions" class="groupMargin hidden js-show"> <h3><?php echo $this->t('{privacyidea:privacyidea:alternate_login_options}'); ?></h3> <!-- Alternate Login Options--> - <?php if (($this->data['webAuthnAvailable'] ?? false) && 'webauthn' !== $this->data['mode']) { ?> + <?php if (($this->data['webauthnAvailable'] ?? false) && 'webauthn' !== $this->data['mode']) { ?> <button id="useWebAuthnButton" name="useWebAuthnButton" type="button"> <span><?php echo $this->t('{privacyidea:privacyidea:webauthn}'); ?></span> </button> -- GitLab