Don't return anything in the response body when unauthenticated (fixes #696)

This commit is contained in:
Bernd Bestel 2020-04-03 18:22:05 +02:00
parent 11bf89e13a
commit 2778d2ad56
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -44,7 +44,7 @@ class SessionAuthMiddleware extends BaseMiddleware
if ((!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName])) && $routeName !== 'login')
{
define('GROCY_AUTHENTICATED', false);
$response = $handler->handle($request);
$response = new \Slim\Psr7\Response(); // No content when unauthorized
$response = $response->withHeader('Location', $this->AppContainer->get('UrlManager')->ConstructUrl('/login'));
}
else