Browse Source
Merge pull request #36489 from nextcloud/bugfix/noid/brute-force-protection-password-reset
Add bruteforce protection to password reset page
pull/36570/head
Joas Schilling
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
6 additions and
1 deletions
-
core/Controller/LostController.php
-
tests/Core/Controller/LostControllerTest.php
|
|
|
@ -128,6 +128,8 @@ class LostController extends Controller { |
|
|
|
* |
|
|
|
* @PublicPage |
|
|
|
* @NoCSRFRequired |
|
|
|
* @BruteForceProtection(action=passwordResetEmail) |
|
|
|
* @AnonRateThrottle(limit=10, period=300) |
|
|
|
*/ |
|
|
|
public function resetform(string $token, string $userId): TemplateResponse { |
|
|
|
try { |
|
|
|
@ -137,12 +139,14 @@ class LostController extends Controller { |
|
|
|
|| ($e instanceof InvalidTokenException |
|
|
|
&& !in_array($e->getCode(), [InvalidTokenException::TOKEN_NOT_FOUND, InvalidTokenException::USER_UNKNOWN])) |
|
|
|
) { |
|
|
|
return new TemplateResponse( |
|
|
|
$response = new TemplateResponse( |
|
|
|
'core', 'error', [ |
|
|
|
"errors" => [["error" => $e->getMessage()]] |
|
|
|
], |
|
|
|
TemplateResponse::RENDER_AS_GUEST |
|
|
|
); |
|
|
|
$response->throttle(); |
|
|
|
return $response; |
|
|
|
} |
|
|
|
return new TemplateResponse('core', 'error', [ |
|
|
|
'errors' => [['error' => $this->l10n->t('Password reset is disabled')]] |
|
|
|
|
|
|
|
@ -171,6 +171,7 @@ class LostControllerTest extends TestCase { |
|
|
|
] |
|
|
|
], |
|
|
|
'guest'); |
|
|
|
$expectedResponse->throttle(); |
|
|
|
$this->assertEquals($expectedResponse, $response); |
|
|
|
} |
|
|
|
|
|
|
|
|