mirror of
https://github.com/openvk/openvk
synced 2024-11-14 02:59:12 +03:00
Users: Fix 2FA QR code generation when new version of chillerlan/php-qrcode is installed
Compatibility with the old version is also preserved
This commit is contained in:
parent
3edf34e0ea
commit
efcaa874fb
2 changed files with 10 additions and 5 deletions
|
@ -448,11 +448,16 @@ final class UserPresenter extends OpenVKPresenter
|
|||
$this->template->secret = $secret;
|
||||
}
|
||||
|
||||
$issuer = OPENVK_ROOT_CONF["openvk"]["appearance"]["name"];
|
||||
$email = $this->user->identity->getEmail();
|
||||
$this->template->qrCode = substr((new QRCode(new QROptions([
|
||||
// Why are these crutch? For some reason, the QR code is not displayed if you just pass the render output to the view
|
||||
|
||||
$issuer = OPENVK_ROOT_CONF["openvk"]["appearance"]["name"];
|
||||
$email = $this->user->identity->getEmail();
|
||||
$qrCode = explode("base64,", (new QRCode(new QROptions([
|
||||
"imageTransparent" => false
|
||||
])))->render("otpauth://totp/$issuer:$email?secret=$secret&issuer=$issuer"), 22);
|
||||
])))->render("otpauth://totp/$issuer:$email?secret=$secret&issuer=$issuer"));
|
||||
|
||||
$this->template->qrCodeType = substr($qrCode[0], 5);
|
||||
$this->template->qrCodeData = $qrCode[1];
|
||||
}
|
||||
|
||||
function renderDisableTwoFactorAuth(): void
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{_"two_factor_authentication_settings_1"|noescape}
|
||||
<p>{_"two_factor_authentication_settings_2"}</p>
|
||||
<div style="text-align: center;">
|
||||
<img src="data:image/png;base64,{$qrCode}">
|
||||
<img width="225" height="225" src="data:{$qrCodeType};base64,{$qrCodeData}">
|
||||
</div>
|
||||
<p>{tr("two_factor_authentication_settings_3", $secret)|noescape}</p>
|
||||
<p>{_"two_factor_authentication_settings_4"}</p>
|
||||
|
|
Loading…
Reference in a new issue