Skip to content

Commit 1fa1a19

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

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
@@ -232,6 +232,13 @@ public function getRoute(string $uri): array
232232
$this->method = $method;
233233
$this->params = $params;
234234

235+
// Prevent access to default controller's method
236+
if (strtolower($baseControllerName) === strtolower($this->defaultController)) {
237+
throw new PageNotFoundException(
238+
'Cannot access the default controller "' . $this->controller . '::' . $this->method . '"'
239+
);
240+
}
241+
235242
// Prevent access to default method path
236243
if (strtolower($this->method) === strtolower($this->defaultMethod)) {
237244
throw new PageNotFoundException(

0 commit comments

Comments
 (0)