Skip to content

Commit

Permalink
Raise exception when QRCode package is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Ribeiro authored and ifox committed Jul 21, 2021
1 parent 5b3640a commit b7a892d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/TwillServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace A17\Twill;

use Exception;
use A17\Twill\Commands\BlockMake;
use A17\Twill\Commands\Build;
use A17\Twill\Commands\CapsuleInstall;
Expand Down Expand Up @@ -86,6 +87,8 @@ public function boot()

$this->extendBlade();
$this->addViewComposers();

$this->check2FA();
}

/**
Expand Down Expand Up @@ -478,4 +481,23 @@ public function version()
{
return static::VERSION;
}

/**
* In case 2FA is enabled, we need to check if a QRCode compatible package is
* installed.
*/
public function check2FA()
{
if (!config('twill.enabled.users-2fa')) {
return;
}

try {
(new User())->get2faQrCode();
} catch (Exception $e) {
throw new Exception(
"Twill ERROR: As you have 2FA enabled, you also need to install a QRCode service package, please check https://github.com/antonioribeiro/google2fa-qrcode#built-in-qrcode-rendering-services"
);
}
}
}

0 comments on commit b7a892d

Please sign in to comment.