Skip to content

Commit b9e68ee

Browse files
committed
feat: prevent access to default controller's method
The default method is still accesible.
1 parent b034979 commit b9e68ee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

system/Router/AutoRouterImproved.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ public function getRoute(string $uri): array
242242
$this->method = $method;
243243
$this->params = $params;
244244

245+
// Prevent access to default controller's method
246+
if (strtolower($baseControllerName) === strtolower($this->defaultController)) {
247+
throw new PageNotFoundException(
248+
'Cannot access the default controller "' . $this->controller . '::' . $this->method . '"'
249+
);
250+
}
251+
245252
// Prevent access to default method path
246253
if (strtolower($this->method) === strtolower($this->defaultMethod)) {
247254
throw new PageNotFoundException(

0 commit comments

Comments
 (0)