]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/front/ShaarliAdminMiddleware.php
3 namespace Shaarli\Front
;
6 use Slim\Http\Response
;
9 * Middleware used for controller requiring to be authenticated.
10 * It extends ShaarliMiddleware, and just make sure that the user is authenticated.
11 * Otherwise, it redirects to the login page.
13 class ShaarliAdminMiddleware
extends ShaarliMiddleware
15 public function __invoke(Request
$request, Response
$response, callable
$next): Response
17 $this->initBasePath($request);
19 if (true !== $this->container
->loginManager
->isLoggedIn()) {
20 $returnUrl = urlencode($this->container
->environment
['REQUEST_URI']);
22 return $response->withRedirect($this->container
->basePath
. '/login?returnurl=' . $returnUrl);
25 return parent
::__invoke($request, $response, $next);