diff --git a/src/Http/Controllers/DcatAuthGoogle2FaAuthController.php b/src/Http/Controllers/DcatAuthGoogle2FaAuthController.php index 8d77347..1160ed8 100644 --- a/src/Http/Controllers/DcatAuthGoogle2FaAuthController.php +++ b/src/Http/Controllers/DcatAuthGoogle2FaAuthController.php @@ -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 ''; + } 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'));