Update SecuritySettings Controller, add 2FA backup code regeneration

This commit is contained in:
Daniel Supernault 2018-12-27 21:32:50 -07:00
parent 2ab70f4344
commit 2eff42bd76
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 13 additions and 0 deletions

View File

@ -110,6 +110,19 @@ trait SecuritySettings
return view('settings.security.2fa.recovery-codes', compact('user', 'codes'));
}
public function securityTwoFactorRecoveryCodesRegenerate(Request $request)
{
$user = Auth::user();
if(!$user->{'2fa_enabled'} || !$user->{'2fa_secret'}) {
abort(403);
}
$backups = $this->generateBackupCodes();
$user->{'2fa_backup_codes'} = json_encode($backups);
$user->save();
return redirect(route('settings.security.2fa.recovery'));
}
public function securityTwoFactorUpdate(Request $request)
{
$user = Auth::user();