0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-13 08:21:47 +00:00

Added throttling to password reset requests

This commit is contained in:
Dan Brown 2021-10-08 23:19:37 +01:00
parent 543ea6ef71
commit ca764caf2d
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
3 changed files with 18 additions and 1 deletions
app
Config
Http/Controllers/Auth
tests/Auth

View file

@ -70,6 +70,7 @@ return [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],

View file

@ -56,7 +56,7 @@ class ForgotPasswordController extends Controller
$this->logActivity(ActivityType::AUTH_PASSWORD_RESET, $request->get('email'));
}
if ($response === Password::RESET_LINK_SENT || $response === Password::INVALID_USER) {
if (in_array($response, [Password::RESET_LINK_SENT, Password::INVALID_USER, Password::RESET_THROTTLED])) {
$message = trans('auth.reset_password_sent', ['email' => $request->get('email')]);
$this->showSuccessNotification($message);

View file

@ -282,6 +282,22 @@ class AuthTest extends TestCase
->assertElementContains('a', 'Sign up');
}
public function test_reset_password_request_is_throttled()
{
$editor = $this->getEditor();
Notification::fake();
$this->get('/password/email');
$this->followingRedirects()->post('/password/email', [
'email' => $editor->email,
]);
$resp = $this->followingRedirects()->post('/password/email', [
'email' => $editor->email,
]);
Notification::assertTimesSent(1, ResetPassword::class);
$resp->assertSee('A password reset link will be sent to ' . $editor->email . ' if that email address is found in the system.');
}
public function test_login_redirects_to_initially_requested_url_correctly()
{
config()->set('app.url', 'http://localhost');