Fix session table missing on start with empty database

This commit is contained in:
Bernd Bestel
2018-04-15 14:49:00 +02:00
parent 5ddae116e0
commit e9bc51ca3d
2 changed files with 12 additions and 5 deletions

View File

@@ -11,14 +11,21 @@ class SessionAuthMiddleware extends BaseMiddleware
$route = $request->getAttribute('route');
$routeName = $route->getName();
$sessionService = new SessionService();
if ((!isset($_COOKIE['grocy_session']) || !$sessionService->IsValidSession($_COOKIE['grocy_session'])) && $routeName !== 'login')
if ($routeName === 'root')
{
$response = $response->withRedirect('/login');
$response = $next($request, $response);
}
else
{
$response = $next($request, $response);
$sessionService = new SessionService();
if ((!isset($_COOKIE['grocy_session']) || !$sessionService->IsValidSession($_COOKIE['grocy_session'])) && $routeName !== 'login')
{
$response = $response->withRedirect('/login');
}
else
{
$response = $next($request, $response);
}
}
return $response;