diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-12-08 08:58:30 +0000 |
|---|---|---|
| committer | David Siegfried <david.siegfried@uni-vechta.de> | 2022-12-08 08:58:30 +0000 |
| commit | cb83c5f6dcc8e176ca2494f699840c27f18f9d8f (patch) | |
| tree | a19055490227143258d1a20d3bf789e458dffa5f | |
| parent | f9887c3c51253cf1a7499fed8f8189c015f5a4aa (diff) | |
resurrect qrcode display, fixes #1861
Closes #1861
Merge request studip/studip!1220
| -rw-r--r-- | resources/assets/javascripts/bootstrap/qr_code.js | 16 | ||||
| -rw-r--r-- | resources/assets/stylesheets/scss/tfa.scss | 15 | ||||
| -rw-r--r-- | templates/tfa-validate.php | 2 |
3 files changed, 28 insertions, 5 deletions
diff --git a/resources/assets/javascripts/bootstrap/qr_code.js b/resources/assets/javascripts/bootstrap/qr_code.js index 3a627f7..9ed0b21 100644 --- a/resources/assets/javascripts/bootstrap/qr_code.js +++ b/resources/assets/javascripts/bootstrap/qr_code.js @@ -8,3 +8,19 @@ $(document).on('click', 'a[data-qr-code]', function (event) { event.preventDefault(); }); + +STUDIP.ready(event => { + $('code.qr', event.target).each(function () { + const text = $(this).text().trim(); + if ($(this).hasClass('hide-text')) { + $(this).text(''); + } + + $(this).qrcode({ + text: text, + width: 1280, + height: 1280, + correctLevel: 3 + }).addClass('has-qr-code'); + }); +}); diff --git a/resources/assets/stylesheets/scss/tfa.scss b/resources/assets/stylesheets/scss/tfa.scss index e6b9390..178eb7a 100644 --- a/resources/assets/stylesheets/scss/tfa.scss +++ b/resources/assets/stylesheets/scss/tfa.scss @@ -1,11 +1,18 @@ .tfa-app-code { code.qr { - display: none; - } - .qrcode img { + display: block; margin: auto; - width: 40%; max-width: 50vw; + width: 40%; + + canvas { + max-width: 100%; + height: auto; + } + + &:not(.has-qr-code) { + display: none; + } } } diff --git a/templates/tfa-validate.php b/templates/tfa-validate.php index 62a5eb3..f5221bc 100644 --- a/templates/tfa-validate.php +++ b/templates/tfa-validate.php @@ -17,7 +17,7 @@ . 'anschliessend ein gültiges Token ein.') ?> </p> <div class="tfa-app-code"> - <code class="qr"><?= $secret->getProvisioningUri() ?></code> + <code class="qr hide-text"><?= $secret->getProvisioningUri() ?></code> </div> <? elseif ($secret->type === 'app' && $secret->confirmed): ?> <p> |
