Fix enable/disable tfa

This commit is contained in:
Joseph Cohen
2015-01-09 14:21:53 -06:00
parent d0d812e4d3
commit 4ea90dcc2e
7 changed files with 31 additions and 23 deletions

View File

@@ -33,11 +33,19 @@ class DashUserController extends Controller
{
$items = Binput::all();
$passwordChange = array_get($items, 'password');
$enable2FA = (bool) array_pull($items, 'google2fa');
// Let's enable/disable auth
$authSecret = $enable2FA && ! Auth::user()->hasEnabled2FA ? Google2FA::generateSecretKey() : '';
$items['google_2fa_secret'] = $authSecret;
if ($enable2FA && ! Auth::user()->hasTwoFactor) {
$items['google_2fa_secret'] = Google2FA::generateSecretKey();
} elseif (! $enable2FA) {
$items['google_2fa_secret'] = '';
}
if (trim($passwordChange) === '') {
unset($items['password']);
}
$updated = Auth::user()->update($items);