mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-06-11 01:20:21 -04:00
Add 'Download QR Code' action link
So the user can download the QR code to backup if they lose access to their device. The download currently does only work in chrome and firefox, but not in safari. The reason is, that the action link uses `ipl\Web\Url` which adds '///' between the schema and the base path. The safari browser can't handle this. 'data:image/png;base64,...' is converted to 'data:///image/png;base64...'.
This commit is contained in:
parent
268c6ddeee
commit
e643dcc413
1 changed files with 18 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ use ipl\Web\Common\CsrfCounterMeasure;
|
|||
use ipl\Web\Common\FormUid;
|
||||
use ipl\Web\Compat\CompatForm;
|
||||
use ipl\Web\Url;
|
||||
use ipl\Web\Widget\ActionLink;
|
||||
use ipl\Web\Widget\CopyToClipboard;
|
||||
|
||||
/**
|
||||
|
|
@ -112,15 +113,28 @@ class TwoFactorConfigForm extends CompatForm
|
|||
$this->twoFactor = TwoFactorTotp::createFromSecret($secret, $this->user->getUsername());
|
||||
}
|
||||
|
||||
$qrCode = $this->twoFactor->createQRCode();
|
||||
|
||||
$this->addHtml(new FakeFormElement(
|
||||
HtmlElement::create('img', Attributes::create([
|
||||
'class' => 'two-factor-totp-qr-code',
|
||||
'src' => $this->twoFactor->createQRCode()
|
||||
])),
|
||||
HtmlElement::create(
|
||||
'img',
|
||||
Attributes::create(['class' => 'two-factor-totp-qr-code', 'src' => $qrCode])
|
||||
),
|
||||
$this->translate('QR Code'),
|
||||
$this->translate('Use your authenticator app to scan the QR code.')
|
||||
));
|
||||
|
||||
$this->addHtml(new FakeFormElement(
|
||||
new ActionLink(
|
||||
'Download QR Code (e.g. for Recovery)',
|
||||
$qrCode,
|
||||
'download',
|
||||
Attributes::create(['download' => 'icinga-web-totp-qr-code.png'])
|
||||
),
|
||||
description: $this->translate('Download the QR code to back up your two-factor'
|
||||
. ' authentication in case you lose access to your device.')
|
||||
));
|
||||
|
||||
$manualAuthUrl = HtmlElement::create(
|
||||
'div',
|
||||
Attributes::create(['class' => 'two-factor-totp-auth-url']),
|
||||
|
|
|
|||
Loading…
Reference in a new issue