Skip to content

Commit

Permalink
Merge pull request #3619 from mxss/upgrade-google2fa
Browse files Browse the repository at this point in the history
upgraded google2fa (0.7->5.0)
  • Loading branch information
jbrooksuk committed Jul 13, 2019
2 parents 3d0322d + 699bf71 commit c6e4447
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 150 deletions.
9 changes: 7 additions & 2 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA;
use PragmaRX\Google2FA\Google2FA;

class AuthController extends Controller
{
Expand Down Expand Up @@ -89,6 +89,10 @@ public function showTwoFactorAuth()
*
* This feels very hacky, but we have to juggle authentication and codes.
*
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postTwoFactor()
Expand All @@ -102,7 +106,8 @@ public function postTwoFactor()

$user = Auth::user();

$valid = Google2FA::verifyKey($user->google_2fa_secret, $code);
$google2fa = new Google2FA();
$valid = $google2fa->verifyKey($user->google_2fa_secret, $code);

if ($valid) {
event(new UserPassedTwoAuthEvent($user));
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Controllers/Dashboard/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA;
use PragmaRX\Google2FA\Google2FA;

class UserController extends Controller
{
Expand All @@ -39,6 +39,9 @@ public function showUser()
/**
* Updates the current user.
*
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
*
* @return \Illuminate\View\View
*/
public function postUser()
Expand All @@ -50,7 +53,8 @@ public function postUser()
// Let's enable/disable auth
if ($enable2FA && !Auth::user()->hasTwoFactor) {
event(new UserEnabledTwoAuthEvent(Auth::user()));
$userData['google_2fa_secret'] = Google2FA::generateSecretKey();
$google2fa = new Google2FA();
$userData['google_2fa_secret'] = $google2fa->generateSecretKey();
} elseif (!$enable2FA) {
event(new UserDisabledTwoAuthEvent(Auth::user()));
$userData['google_2fa_secret'] = '';
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"alt-three/validator": "^4.1",
"aws/aws-sdk-php": "^3.7",
"barryvdh/laravel-cors": "^0.11.0",
"chillerlan/php-qrcode": "^2.0",
"doctrine/dbal": "2.9.*",
"fideloper/proxy": "^4.0",
"graham-campbell/binput": "^6.0",
Expand All @@ -51,7 +52,7 @@
"laravel/tinker": "^1.0",
"mccool/laravel-auto-presenter": "^7.1",
"nexmo/client": "^1.5",
"pragmarx/google2fa": "^0.7.1",
"pragmarx/google2fa": "^5.0",
"predis/predis": "^1.1",
"twig/twig": "^2.6"
},
Expand Down
Loading

0 comments on commit c6e4447

Please sign in to comment.