From ec9da1709bdffc757f0f4b20958dbaf3c70ca357 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 3 Aug 2017 03:02:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B2?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=BB=D0=B5=20qr=20=D0=B7=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D0=B0=20/api/two-factor-auth=20=D0=B2=D0=BE=D0=B7?= =?UTF-8?q?=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BA=D0=B0=20=D1=81=20svg=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=B7=20base64,=20=D0=BD=D0=B0=D1=87=D0=B8=D0=BD=D0=B0=D1=8E?= =?UTF-8?q?=D1=89=D0=B0=D1=8F=D1=81=D1=8F=20=D1=81=20data:image/svg+xml,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/models/profile/TwoFactorAuthForm.php | 2 +- .../api/unit/models/profile/TwoFactorAuthFormTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/models/profile/TwoFactorAuthForm.php b/api/models/profile/TwoFactorAuthForm.php index 275ec97..1f2b47f 100644 --- a/api/models/profile/TwoFactorAuthForm.php +++ b/api/models/profile/TwoFactorAuthForm.php @@ -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, ]; diff --git a/tests/codeception/api/unit/models/profile/TwoFactorAuthFormTest.php b/tests/codeception/api/unit/models/profile/TwoFactorAuthFormTest.php index 780652c..36435f1 100644 --- a/tests/codeception/api/unit/models/profile/TwoFactorAuthFormTest.php +++ b/tests/codeception/api/unit/models/profile/TwoFactorAuthFormTest.php @@ -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,<_/>', $result['qr']); /** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */ $account = $this->getMockBuilder(Account::class)