Skip to content

Commit a92d1d1

Browse files
authored
Merge pull request #28742 from nextcloud/backport/28725/stable20
[stable20] Remove 2FA exemption from PublicPage annotation
2 parents e7f6692 + 65b4c6f commit a92d1d1

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

core/Middleware/TwoFactorMiddleware.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ public function __construct(Manager $twoFactorManager, Session $userSession, ISe
8383
* @param string $methodName
8484
*/
8585
public function beforeController($controller, $methodName) {
86-
if ($this->reflector->hasAnnotation('PublicPage')) {
87-
// Don't block public pages
88-
return;
89-
}
90-
9186
if ($controller instanceof TwoFactorChallengeController
9287
&& $this->userSession->getUser() !== null
9388
&& !$this->reflector->hasAnnotation('TwoFactorSetUpDoneRequired')) {

tests/Core/Middleware/TwoFactorMiddlewareTest.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ protected function setUp(): void {
9797
}
9898

9999
public function testBeforeControllerNotLoggedIn() {
100-
$this->reflector->expects($this->once())
101-
->method('hasAnnotation')
102-
->with('PublicPage')
103-
->willReturn(false);
104100
$this->userSession->expects($this->once())
105101
->method('isLoggedIn')
106102
->willReturn(false);
@@ -111,24 +107,9 @@ public function testBeforeControllerNotLoggedIn() {
111107
$this->middleware->beforeController($this->controller, 'index');
112108
}
113109

114-
public function testBeforeControllerPublicPage() {
115-
$this->reflector->expects($this->once())
116-
->method('hasAnnotation')
117-
->with('PublicPage')
118-
->willReturn(true);
119-
$this->userSession->expects($this->never())
120-
->method('isLoggedIn');
121-
122-
$this->middleware->beforeController($this->controller, 'create');
123-
}
124-
125110
public function testBeforeSetupController() {
126111
$user = $this->createMock(IUser::class);
127112
$controller = $this->createMock(ALoginSetupController::class);
128-
$this->reflector->expects($this->once())
129-
->method('hasAnnotation')
130-
->with('PublicPage')
131-
->willReturn(false);
132113
$this->userSession->expects($this->any())
133114
->method('getUser')
134115
->willReturn($user);
@@ -144,10 +125,6 @@ public function testBeforeSetupController() {
144125
public function testBeforeControllerNoTwoFactorCheckNeeded() {
145126
$user = $this->createMock(IUser::class);
146127

147-
$this->reflector->expects($this->once())
148-
->method('hasAnnotation')
149-
->with('PublicPage')
150-
->willReturn(false);
151128
$this->userSession->expects($this->once())
152129
->method('isLoggedIn')
153130
->willReturn(true);
@@ -168,10 +145,6 @@ public function testBeforeControllerTwoFactorAuthRequired() {
168145

169146
$user = $this->createMock(IUser::class);
170147

171-
$this->reflector->expects($this->once())
172-
->method('hasAnnotation')
173-
->with('PublicPage')
174-
->willReturn(false);
175148
$this->userSession->expects($this->once())
176149
->method('isLoggedIn')
177150
->willReturn(true);

0 commit comments

Comments
 (0)