2022-04-24 14:32:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package Grav\Plugin\Login
|
|
|
|
*
|
|
|
|
* @copyright Copyright (C) 2014 - 2021 RocketTheme, LLC. All rights reserved.
|
|
|
|
* @license MIT License; see LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Grav\Plugin\Login\TwoFactorAuth;
|
|
|
|
|
2023-05-12 15:06:01 +02:00
|
|
|
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
|
|
|
|
use BaconQrCode\Renderer\ImageRenderer as BaconImageRenderer;
|
|
|
|
use BaconQrCode\Renderer\RendererStyle\RendererStyle as BaconRendererStyle;
|
2022-04-24 14:32:58 +02:00
|
|
|
use BaconQrCode\Writer as BaconWriter;
|
|
|
|
use RobThree\Auth\Providers\Qr\IQRCodeProvider;
|
|
|
|
|
|
|
|
class BaconQrProvider implements IQRCodeProvider
|
|
|
|
{
|
|
|
|
public function getMimeType()
|
|
|
|
{
|
2023-05-12 15:06:01 +02:00
|
|
|
return 'image/svg+xml';
|
2022-04-24 14:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getQRCodeImage($qrtext, $size = 256)
|
|
|
|
{
|
2023-05-12 15:06:01 +02:00
|
|
|
$renderer = new BaconImageRenderer(
|
|
|
|
new BaconRendererStyle((int) $size),
|
|
|
|
new SvgImageBackEnd()
|
|
|
|
);
|
|
|
|
|
2022-04-24 14:32:58 +02:00
|
|
|
$writer = new BaconWriter($renderer);
|
|
|
|
|
|
|
|
return $writer->writeString($qrtext);
|
|
|
|
}
|
|
|
|
}
|