Select Git revision
tfa-validate.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Closes #1861 Merge request studip/studip!1220
Closes #1861 Merge request studip/studip!1220
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
tfa-validate.php 2.97 KiB
<form action="<?= htmlReady(Request::url()) ?>" method="post" class="default">
<input type="hidden" name="tfa-nonce" value="<?= htmlReady($__nonce) ?>">
<fieldset>
<legend><?= _('Zwei-Faktor-Authentifizierung') ?></legend>
<? if ($blocked): ?>
<?= MessageBox::warning(_('Sie haben zu viele ungültige Versuche'), [sprintf(
_('Versuchen Sie es in %u Minute(n) erneut'),
ceil((time() - $blocked) / 60)
)])->hideClose() ?>
<? else: ?>
<p><?= htmlReady($text ?: _('Bitte geben Sie ein gültiges Token ein')) ?></p>
<? if ($secret->type === 'app' && !$secret->confirmed): ?>
<?= formatReady(Config::get()->TFA_TEXT_APP) ?>
<p>
<?= _('Scannen Sie diesen Code mit Ihrer App ein und geben Sie '
. 'anschliessend ein gültiges Token ein.') ?>
</p>
<div class="tfa-app-code">
<code class="qr hide-text"><?= $secret->getProvisioningUri() ?></code>
</div>
<? elseif ($secret->type === 'app' && $secret->confirmed): ?>
<p>
<?= _('Das notwendige Token wird von der von Ihnen verknüpften App generiert.') ?>
</p>
<? elseif ($secret->type === 'email'): ?>
<p>
<?= sprintf(
_('Das notwendige Token wurde Ihnen per E-Mail zugesendet und ist %u Minuten gültig.'),
TFASecret::getValidationDuration('email') / 60
) ?>
</p>
<? endif; ?>
<div class="tfa-code-input">
<? ob_start(); ?>
<div class="tfa-code-wrapper">
<? for ($i = 0; $i < 6; $i += 1): ?>
<input required type="number" name="tfacode-input[<?= $i ?>]" value=""
max="9" pattern="[0-9]*" maxlength="1" class="no-hint"
<? if ($i === 0) echo 'autofocus'; ?>>
<? endfor; ?>
</div>
<?php
// We need to strip all whitespace between html nodes so that they have no
// visual gap between them.
$__content = ob_get_clean();
$__content = trim($__content);
$__content = preg_replace('/>\s+</', '><', $__content);
print $__content;
?>
</div>
<? if ($global): ?>
<label>
<input type="checkbox" name="tfa-trusted" value="1">
<? if ($duration > 0): ?>
<?= sprintf(
ngettext(
'Diesem Gerät für %u Tag vertrauen.',
'Diesem Gerät für %u Tage vertrauen.',
$duration
),
$duration
) ?>
<? else: ?>
<?= _('Diesem Gerät dauerhaft vertrauen') ?>
<? endif; ?>
</label>
<? endif; ?>