about summary refs log tree commit diff stats
path: root/classes/CsrfMiddleware.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-26 11:06:30 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-26 11:06:30 +0300
commitfa1bccd968647f6ab5cce0ec4293b39c6fde7633 (patch)
treea51b489a43bdfcc2688bd0855cf3e32382ad958c /classes/CsrfMiddleware.php
parentab7702f0e3dd63bdeaea3cb6db138878774c3b47 (diff)
downloadthe-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.gz
the-epube-fa1bccd968647f6ab5cce0ec4293b39c6fde7633.tar.xz
spaces to tabs
Diffstat (limited to 'classes/CsrfMiddleware.php')
-rw-r--r--classes/CsrfMiddleware.php40
1 files changed, 20 insertions, 20 deletions
diff --git a/classes/CsrfMiddleware.php b/classes/CsrfMiddleware.php
index 9693f99..3977241 100644
--- a/classes/CsrfMiddleware.php
+++ b/classes/CsrfMiddleware.php
@@ -2,29 +2,29 @@
 
 class CsrfMiddleware implements MiddlewareInterface
 {
-    /** @var array<string> */
-    private array $csrfIgnore = [
-        "cover", "download", "getpagination", "getlastread", "getinfo", "list"
-    ];
+	/** @var array<string> */
+	private array $csrfIgnore = [
+		"cover", "download", "getpagination", "getlastread", "getinfo", "list"
+	];
 
-    public function process(Request $request, callable $next): Response
-    {
-        if (empty($_SESSION['owner'])) {
-            return $next($request);
-        }
+	public function process(Request $request, callable $next): Response
+	{
+		if (empty($_SESSION['owner'])) {
+			return $next($request);
+		}
 
-        $op = $request->getAttribute('op');
+		$op = $request->getAttribute('op');
 
-        $csrfToken = $request->getAttribute('csrf_token', '');
+		$csrfToken = $request->getAttribute('csrf_token', '');
 
-        if (!in_array($op, $this->csrfIgnore) && !validate_csrf($csrfToken)) {
-            $response = (new Response())
-                ->withStatus(401)
-                ->withBody("Unauthorized (CSRF)");
-            $response->send();
-            exit;
-        }
+		if (!in_array($op, $this->csrfIgnore) && !validate_csrf($csrfToken)) {
+			$response = (new Response())
+				->withStatus(401)
+				->withBody("Unauthorized (CSRF)");
+			$response->send();
+			exit;
+		}
 
-        return $next($request);
-    }
+		return $next($request);
+	}
 }