Skip to content

Commit

Permalink
🐛修复对chillerlan\QRCode\QRCode包的兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
C0003308 committed Nov 8, 2023
1 parent 7432682 commit e54166f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Http/Controllers/DcatAuthGoogle2FaAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,20 @@ protected function settingForm()
$url = $google2fa->getQRCodeInline(config('admin.name'), $user->username, $googleTwoFaSecret);
$form->display('google_2fa_qrcode', DcatAuthGoogle2FaServiceProvider::trans('dcat-auth-google-2fa.google_2fa_qrcode'))
->help(DcatAuthGoogle2FaServiceProvider::trans('dcat-auth-google-2fa.google_2fa_qrcode_help'))
->with(function () use ($url) {
return $url;
->width(2)
->with(function () use ($url, $google2fa) {
if (
class_exists('BaconQrCode\Writer') &&
class_exists('BaconQrCode\Renderer\ImageRenderer')
) {
return $url;
} elseif (class_exists('chillerlan\QRCode\QRCode')) {
return '<img src="' . $url . '" />';
} else {
throw new MissingQrCodeServiceException(
DcatAuthGoogle2FaServiceProvider::trans('dcat-auth-google-2fa.qrcode_service_tips')
);
}
});
$form->text('google_2fa_code', DcatAuthGoogle2FaServiceProvider::trans('dcat-auth-google-2fa.google_2fa_code'))
->help(DcatAuthGoogle2FaServiceProvider::trans('dcat-auth-google-2fa.google_2fa_code_enable_help'));
Expand Down

0 comments on commit e54166f

Please sign in to comment.