laravel-lib / gauth
Google Authenticator for Laravel
v1.0.0
2022-03-11 08:25 UTC
Requires
- php: ^7.4|^8.0|^8.1
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/phpunit-bridge: ^6.0
README
Installation
composer require laravel-lib/gauth
Usage
To generate secret code
$secret_code = GAuth::generateSecret();
To generate QR Code URL image
$secret_code = GAuth::generateSecret();
$qrcode_img_url = GAuth::generateQrUrl('foo@bar.com', $secret_code, 'My App Name); // No semicolon (:) on App Name
To check the qrcode
$secret_code = GAuth::generateSecret();
$user_input = '123456';
if (!GAuth::checkCode($secret_code, $user_input)) {
die('The code is invalid !');
return;
}
To get current code
$secret_code = GAuth::generateSecret();
$current_code = GAuth::getCode($secret_code);