mirror of
https://github.com/elyby/accounts.git
synced 2025-01-11 14:32:12 +05:30
Добавлено экранирование # символа в QR коде
This commit is contained in:
parent
01850bb2d6
commit
013ddd1b1b
@ -22,7 +22,7 @@ class TwoFactorAuthInfo extends BaseAccountForm {
|
|||||||
$provisioningUri = $this->getTotp()->getProvisioningUri();
|
$provisioningUri = $this->getTotp()->getProvisioningUri();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'qr' => 'data:image/svg+xml,' . trim($this->drawQrCode($provisioningUri)),
|
'qr' => $this->buildDataImage($this->drawQrCode($provisioningUri)),
|
||||||
'uri' => $provisioningUri,
|
'uri' => $provisioningUri,
|
||||||
'secret' => $this->getAccount()->otp_secret,
|
'secret' => $this->getAccount()->otp_secret,
|
||||||
];
|
];
|
||||||
@ -41,6 +41,14 @@ class TwoFactorAuthInfo extends BaseAccountForm {
|
|||||||
return $writer->writeString($content, Encoder::DEFAULT_BYTE_MODE_ECODING, ErrorCorrectionLevel::H);
|
return $writer->writeString($content, Encoder::DEFAULT_BYTE_MODE_ECODING, ErrorCorrectionLevel::H);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildDataImage(string $svg) {
|
||||||
|
$svg = trim($svg);
|
||||||
|
// https://stackoverflow.com/a/30733736/5184751
|
||||||
|
$svg = str_replace('#', '%23', $svg);
|
||||||
|
|
||||||
|
return 'data:image/svg+xml,' . $svg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $length
|
* @param int $length
|
||||||
* @throws ThisShouldNotHappenException
|
* @throws ThisShouldNotHappenException
|
||||||
|
Loading…
x
Reference in New Issue
Block a user