mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Add a small check to ask to wait one hour between two recoveries of an account
This commit is contained in:
parent
459e8faf9d
commit
b6b54802d2
2 changed files with 11 additions and 1 deletions
|
|
@ -339,6 +339,12 @@ class Account extends Authenticatable
|
|||
->exists();
|
||||
}
|
||||
|
||||
public function failedRecentRecovery(): bool
|
||||
{
|
||||
$oneHourAgo = Carbon::now()->subHour();
|
||||
return !empty($this->recovery_code) && $this->updated_at->greaterThan($oneHourAgo);
|
||||
}
|
||||
|
||||
public function updatePassword($newPassword, string $algorithm = 'SHA-256')
|
||||
{
|
||||
$this->passwords()->delete();
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@ class RecoveryController extends Controller
|
|||
return redirect()->back()->withErrors(['identifier' => 'The account doesn\'t exists']);
|
||||
}
|
||||
|
||||
if ($account->failedRecentRecovery()) {
|
||||
return redirect()->back()->withErrors(['code' => 'Account recovered recently, try again later']);
|
||||
}
|
||||
|
||||
if ($request->get('email')) {
|
||||
$account = (new AccountService)->recoverByEmail($account);
|
||||
} elseif ($request->get('phone')) {
|
||||
|
|
@ -112,7 +116,7 @@ class RecoveryController extends Controller
|
|||
return redirect()->route($request->get('method') == 'phone'
|
||||
? 'account.recovery.show.phone'
|
||||
: 'account.recovery.show.email')->withErrors([
|
||||
'code' => 'The code entered was not valid'
|
||||
'code' => 'The code entered was not valid, try again later'
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue