Теперь в поле qr запроса /api/two-factor-auth возвращается строка с svg без base64, начинающаяся с data:image/svg+xml,

This commit is contained in:
ErickSkrauch 2017-08-03 03:02:51 +03:00
parent c8db2f4b3f
commit ec9da1709b
2 changed files with 3 additions and 3 deletions

View File

@ -63,7 +63,7 @@ class TwoFactorAuthForm extends ApiForm {
$provisioningUri = $this->getTotp()->getProvisioningUri();
return [
'qr' => base64_encode($this->drawQrCode($provisioningUri)),
'qr' => 'data:image/svg+xml,' . htmlspecialchars(trim($this->drawQrCode($provisioningUri))),
'uri' => $provisioningUri,
'secret' => $this->account->otp_secret,
];

View File

@ -35,7 +35,7 @@ class TwoFactorAuthFormTest extends TestCase {
$model->expects($this->once())
->method('drawQrCode')
->willReturn('this is qr code, trust me');
->willReturn('<_/>');
$result = $model->getCredentials();
$this->assertTrue(is_array($result));
@ -44,7 +44,7 @@ class TwoFactorAuthFormTest extends TestCase {
$this->assertArrayHasKey('secret', $result);
$this->assertNotNull($account->otp_secret);
$this->assertEquals($account->otp_secret, $result['secret']);
$this->assertEquals(base64_encode('this is qr code, trust me'), $result['qr']);
$this->assertEquals('data:image/svg+xml,&lt;_/&gt;', $result['qr']);
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
$account = $this->getMockBuilder(Account::class)