Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/Controller/TwoFactorChallengeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
* @TwoFactorSetUpDoneRequired
*
* @UserRateThrottle(limit=5, period=100)
* @BruteForceProtection(action=solveChallenge)
*
* @param string $challengeProviderId
* @param string $challenge
Expand Down Expand Up @@ -209,10 +210,12 @@
}

$this->session->set('two_factor_auth_error', true);
return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.showChallenge', [
$response = new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.showChallenge', [
'challengeProviderId' => $provider->getId(),
'redirect_url' => $redirect_url,
]));
$response->throttle(['user' => $uid, 'provider' => $challengeProviderId]);

Check failure on line 217 in core/Controller/TwoFactorChallengeController.php

View workflow job for this annotation

GitHub Actions / Psalm

Cannot find referenced variable $uid (see https://psalm.dev/024)

Check failure on line 217 in core/Controller/TwoFactorChallengeController.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedVariable

core/Controller/TwoFactorChallengeController.php:217:34: UndefinedVariable: Cannot find referenced variable $uid (see https://psalm.dev/024)
return $response;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/Core/Controller/TwoFactorChallengeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public function testSolveChallengeInvalidProvider() {

public function testSolveInvalidChallenge() {
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('myuser');
$provider = $this->createMock(IProvider::class);

$this->userSession->expects($this->once())
Expand Down Expand Up @@ -288,11 +289,13 @@ public function testSolveInvalidChallenge() {
->willReturn('myprovider');

$expected = new RedirectResponse('files/index/url');
$expected->throttle(['user' => 'myuser', 'provider' => 'myprovider']);
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token', '/url'));
}

public function testSolveChallengeTwoFactorException() {
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('myuser');
$provider = $this->createMock(IProvider::class);
$exception = new TwoFactorException("2FA failed");

Expand Down Expand Up @@ -326,6 +329,7 @@ public function testSolveChallengeTwoFactorException() {
->willReturn('myprovider');

$expected = new RedirectResponse('files/index/url');
$expected->throttle(['user' => 'myuser', 'provider' => 'myprovider']);
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token', '/url'));
}

Expand Down
Loading