1
0
Fork 0
forked from mirror/pixelfed

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

View file

@ -110,6 +110,19 @@ trait SecuritySettings
return view('settings.security.2fa.recovery-codes', compact('user', 'codes')); 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) public function securityTwoFactorUpdate(Request $request)
{ {
$user = Auth::user(); $user = Auth::user();