diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-08-13 11:08:13 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-08-13 11:08:13 +0200 |
commit | bedbb845eec20363b928b424143787dbe988eefe (patch) | |
tree | 6b835ca247e39157b333323a539dde3c410c08f5 /application/front/ShaarliMiddleware.php | |
parent | 1a68ae5a29bc33ab80c9cfbe043cb1213551533c (diff) | |
download | Shaarli-bedbb845eec20363b928b424143787dbe988eefe.tar.gz Shaarli-bedbb845eec20363b928b424143787dbe988eefe.tar.zst Shaarli-bedbb845eec20363b928b424143787dbe988eefe.zip |
Move all admin controller into a dedicated group
Also handle authentication check in a new middleware for the admin group.
Diffstat (limited to 'application/front/ShaarliMiddleware.php')
-rw-r--r-- | application/front/ShaarliMiddleware.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php index 707489d0..a2a3837b 100644 --- a/application/front/ShaarliMiddleware.php +++ b/application/front/ShaarliMiddleware.php | |||
@@ -40,7 +40,7 @@ class ShaarliMiddleware | |||
40 | */ | 40 | */ |
41 | public function __invoke(Request $request, Response $response, callable $next): Response | 41 | public function __invoke(Request $request, Response $response, callable $next): Response |
42 | { | 42 | { |
43 | $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/'); | 43 | $this->initBasePath($request); |
44 | 44 | ||
45 | try { | 45 | try { |
46 | if (!is_file($this->container->conf->getConfigFileExt()) | 46 | if (!is_file($this->container->conf->getConfigFileExt()) |
@@ -125,4 +125,14 @@ class ShaarliMiddleware | |||
125 | 125 | ||
126 | return true; | 126 | return true; |
127 | } | 127 | } |
128 | |||
129 | /** | ||
130 | * Initialize the URL base path if it hasn't been defined yet. | ||
131 | */ | ||
132 | protected function initBasePath(Request $request): void | ||
133 | { | ||
134 | if (null === $this->container->basePath) { | ||
135 | $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/'); | ||
136 | } | ||
137 | } | ||
128 | } | 138 | } |