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:
Maxim Leshchenko 2022-01-06 00:31:21 +02:00
parent 3edf34e0ea
commit efcaa874fb
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
2 changed files with 10 additions and 5 deletions

View file

@ -448,11 +448,16 @@ final class UserPresenter extends OpenVKPresenter
$this->template->secret = $secret;
}
// 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();
$this->template->qrCode = substr((new QRCode(new QROptions([
$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

View file

@ -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>