mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
New ability to disable 2fa.
Signed-off-by: James Cole <thegrumpydictator@gmail.com>
This commit is contained in:
parent
ccd55257cd
commit
5310ccebbe
@ -43,6 +43,19 @@ class PreferencesController extends Controller
|
||||
return view('preferences.code', compact('secret', 'image'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function deleteCode()
|
||||
{
|
||||
Preferences::delete('twoFactorAuthEnabled');
|
||||
Preferences::delete('twoFactorAuthSecret');
|
||||
Session::flash('success', strval(trans('firefly.pref_two_factor_auth_disabled')));
|
||||
Session::flash('info', strval(trans('firefly.pref_two_factor_auth_remove_it')));
|
||||
|
||||
return redirect(route('preferences'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ARI $repository
|
||||
*
|
||||
|
@ -247,6 +247,7 @@ Route::group(
|
||||
Route::get('/preferences', ['uses' => 'PreferencesController@index', 'as' => 'preferences']);
|
||||
Route::post('/preferences', ['uses' => 'PreferencesController@postIndex']);
|
||||
Route::get('/preferences/code', ['uses' => 'PreferencesController@code', 'as' => 'preferences.code']);
|
||||
Route::get('/preferences/delete-code', ['uses' => 'PreferencesController@deleteCode', 'as' => 'preferences.delete-code']);
|
||||
Route::post('/preferences/code', ['uses' => 'PreferencesController@postCode']);
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,25 @@ use FireflyIII\Models\Preference;
|
||||
*/
|
||||
class Preferences
|
||||
{
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete($name): bool
|
||||
{
|
||||
$fullName = 'preference' . Auth::user()->id . $name;
|
||||
if (Cache::has($fullName)) {
|
||||
Cache::forget($fullName);
|
||||
}
|
||||
/** @var Preference $preference */
|
||||
$preference = Preference::where('user_id', Auth::user()->id)->where('name', $name)->first();
|
||||
$preference->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $default
|
||||
|
@ -230,9 +230,13 @@ return [
|
||||
'pref_two_factor_auth' => '2-step verification',
|
||||
'pref_two_factor_auth_help' => 'When you enable 2-step verification (also known as two-factor authentication), you add an extra layer of security to your account. You sign in with something you know (your password) and something you have (a verification code). Verification codes are generated by an application on your phone, such as Authy or Google Authenticator.',
|
||||
'pref_enable_two_factor_auth' => 'Enable 2-step verification',
|
||||
'pref_two_factor_auth_disabled' => '2-step verification code removed and disabled',
|
||||
'pref_two_factor_auth_remove_it' => 'Don\'t forget to remove the account from your authentication app!',
|
||||
'pref_two_factor_auth_code' => 'Verify code',
|
||||
'pref_two_factor_auth_code_help' => 'Scan the QR code with an application on your phone such as Authy or Google Authenticator and enter the generated code.',
|
||||
'pref_two_factor_auth_reset_code' => 'Reset verification code',
|
||||
'pref_two_factor_auth_remove_code' => 'Remove verification code',
|
||||
'pref_two_factor_auth_remove_will_disable' => '(this will also disable two-factor authentication)',
|
||||
'pref_save_settings' => 'Save settings',
|
||||
|
||||
// profile:
|
||||
|
@ -160,7 +160,13 @@
|
||||
<div class="col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<a href="{{ URL.to('/preferences/code') }}">{{ 'pref_two_factor_auth_reset_code'|_ }}</a>
|
||||
<a href="{{ route('preferences.code') }}">{{ 'pref_two_factor_auth_reset_code'|_ }}</a>
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<a href="{{ route('preferences.delete-code') }}">{{ 'pref_two_factor_auth_remove_code'|_ }}</a>
|
||||
{{ 'pref_two_factor_auth_remove_will_disable'|_ }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user