Update SecuritySettings, remove imagick depdency for 2FA qr code generation image

This commit is contained in:
Daniel Supernault 2023-04-26 02:34:44 -06:00
parent aaf5b2764e
commit 506f95c6b1
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 7 additions and 5 deletions

View file

@ -16,7 +16,7 @@ use Carbon\Carbon;
use Illuminate\Http\Request;
use PragmaRX\Google2FA\Google2FA;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
@ -56,13 +56,15 @@ trait SecuritySettings
$key,
500
);
$writer = new Writer(
new ImageRenderer(
new RendererStyle(400),
new ImagickImageBackEnd()
new SvgImageBackEnd()
)
);
$qrcode = base64_encode($writer->writeString($qrcode));
$qrcode = $writer->writeString($qrcode);
$user->{'2fa_secret'} = $key;
$user->{'2fa_backup_codes'} = json_encode($backups);
$user->save();
@ -162,4 +164,4 @@ trait SecuritySettings
'msg' => 'Successfully removed 2fa device'
], 200);
}
}
}

View file

@ -50,7 +50,7 @@
<div class="card-body text-center">
<div class="pb-3">
<p class="font-weight-bold">QR Code</p>
<img src="data:image/png;base64,{{$qrcode}}" class="img-fluid" width="200px">
{!!$qrcode!!}
</div>
<div>
<p class="font-weight-bold">OTP Secret</p>