Skip to content

Commit ba6a249

Browse files
committed
fix: Only redirect to valid URLs after Panel login
Fixes #6682
1 parent ce4f14b commit ba6a249

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/Panel/Home.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,21 @@ public static function hasAccess(User $user, string $path): bool
118118
return false;
119119
}
120120

121-
// if auth is not required the redirect is allowed
122-
if ($auth === false) {
123-
return true;
121+
// check the firewall, if auth is required
122+
if (
123+
$auth !== false &&
124+
Panel::hasAccess($user, $areaId) === false
125+
) {
126+
return false;
124127
}
125128

126-
// check the firewall
127-
return Panel::hasAccess($user, $areaId);
129+
// check if the route yields a valid result
130+
$result = $route->action()->call(
131+
$route,
132+
...$route->arguments()
133+
);
134+
135+
return $result !== false;
128136
});
129137
} catch (Throwable) {
130138
return false;

tests/Panel/HomeTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ public function testHasAccess(): void
179179
],
180180
'users' => [
181181
['email' => 'test@getkirby.com', 'role' => 'admin']
182+
],
183+
'options' => [
184+
'api' => [
185+
'allowImpersonation' => true
186+
]
182187
]
183188
]);
184189

@@ -220,6 +225,11 @@ public function testHasAccessWithLimitedAccess(): void
220225
],
221226
'users' => [
222227
['email' => 'test@getkirby.com', 'role' => 'editor']
228+
],
229+
'options' => [
230+
'api' => [
231+
'allowImpersonation' => true
232+
]
223233
]
224234
]);
225235

0 commit comments

Comments
 (0)