Skip to content

Commit

Permalink
Fixes errors the auto crsf loading
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed May 18, 2023
1 parent 67ccada commit 7ba401f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Router/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function setBaseRoute(string $base_route): void
* Note: Disable only you run on test env
*
* @param bool $auto_csrf
* @return void
*/
public function setAutoCsrf(bool $auto_csrf): void
{
Expand Down Expand Up @@ -151,10 +152,10 @@ public function prefix(string $prefix, callable $cb): Router
/**
* Allows to associate a global middleware on an route
*
* @param array $middlewares
* @param array|string $middlewares
* @return Router
*/
public function middleware(array $middlewares): Router
public function middleware(array|string $middlewares): Router
{
$middlewares = (array) $middlewares;

Expand Down Expand Up @@ -395,10 +396,9 @@ private function routeLoader(string $method, string $path, callable|string|array

static::$routes[$method][] = $route;

if (app_env('APP_ENV') != 'production' && $this->auto_csrf === true) {
if (in_array($method, ['POST', 'DELETE', 'PUT'])) {
$route->middleware('csrf');
}
if ($this->auto_csrf === true
&& in_array($method, ['POST', 'DELETE', 'PUT'])) {
$route->middleware('csrf');
}

return $route;
Expand Down

0 comments on commit 7ba401f

Please sign in to comment.