Skip to content

Commit

Permalink
refactor: Simplify OCS check
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Jan 10, 2024
1 parent d60f991 commit e7cb49c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions generate-spec
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ if (count($parsedRoutes) == 0) {

$routes = [];
foreach ($parsedRoutes as $key => $value) {
if ($key != "routes" && $key != "ocs") {
$isOCS = $key === "ocs";
$isIndex = $key === "routes";

if (!$isOCS && !$isIndex) {
continue;
}

foreach ($value as $route) {
$routeName = $route["name"];

Expand All @@ -253,10 +257,10 @@ foreach ($parsedRoutes as $key => $value) {
if (str_ends_with($url, "/")) {
$url = substr($url, 0, -1);
}
if ($key == "routes") {
if ($isIndex) {
$url = "/index.php" . $root . $url;
}
if ($key == "ocs") {
if ($isOCS) {
$url = "/ocs/v2.php" . $root . $url;
}

Expand Down Expand Up @@ -320,7 +324,6 @@ foreach ($parsedRoutes as $key => $value) {
}

$isCSRFRequired = !Helpers::classMethodHasAnnotationOrAttribute($methodFunction, "NoCSRFRequired");
$isOCS = $controllerClass->extends != "Controller" && $controllerClass->extends != "ApiController";
if ($isCSRFRequired && !$isOCS) {
Logger::debug($routeName, "Route ignored because of required CSRF in a non-OCS controller");
continue;
Expand Down

0 comments on commit e7cb49c

Please sign in to comment.