mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Fix usage of Google2FA Facade (#6864)
This commit is contained in:
parent
83257af267
commit
b779e274cc
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Services\LdapAd;
|
||||
use Com\Tecnick\Barcode\Barcode;
|
||||
use Google2FA;
|
||||
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -214,19 +215,27 @@ class LoginController extends Controller
|
|||
return redirect()->route('two-factor')->with('error', trans('auth/message.two_factor.already_enrolled'));
|
||||
}
|
||||
|
||||
$google2fa = new Google2FA();
|
||||
$secret = $google2fa->generateSecretKey();
|
||||
$secret = Google2FA::generateSecretKey();
|
||||
$user->two_factor_secret = $secret;
|
||||
$user->save();
|
||||
|
||||
$google2fa_url = $google2fa->getQRCodeGoogleUrl(
|
||||
urlencode(Setting::getSettings()->site_name),
|
||||
$barcode = new Barcode();
|
||||
$barcode_obj =
|
||||
$barcode->getBarcodeObj(
|
||||
'QRCODE',
|
||||
sprintf(
|
||||
'otpauth://totp/%s:%s?secret=%s&issuer=Snipe-IT&period=30',
|
||||
urlencode($settings->site_name),
|
||||
urlencode($user->username),
|
||||
$user->two_factor_secret
|
||||
urlencode($secret)
|
||||
),
|
||||
300,
|
||||
300,
|
||||
'black',
|
||||
[-2, -2, -2, -2]
|
||||
);
|
||||
|
||||
return view('auth.two_factor_enroll')->with('google2fa_url', $google2fa_url);
|
||||
|
||||
return view('auth.two_factor_enroll')->with('barcode_obj', $barcode_obj);
|
||||
}
|
||||
|
||||
|
||||
|
@ -277,10 +286,9 @@ class LoginController extends Controller
|
|||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$google2fa = new Google2FA();
|
||||
$secret = $request->input('two_factor_secret');
|
||||
|
||||
if ($google2fa->verifyKey($user->two_factor_secret, $secret)) {
|
||||
if (Google2FA::verifyKey($user->two_factor_secret, $secret)) {
|
||||
$user->two_factor_enrolled = 1;
|
||||
$user->save();
|
||||
$request->session()->put('2fa_authed', 'true');
|
||||
|
|
Loading…
Reference in a new issue