mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Don't expose username when not logged in
This commit is contained in:
parent
bbb5f1c7c7
commit
ab8094e1c0
@ -21,6 +21,7 @@ class SessionAuthMiddleware extends BaseMiddleware
|
||||
|
||||
if ($routeName === 'root' || $this->ApplicationService->IsDemoInstallation())
|
||||
{
|
||||
define('AUTHENTICATED', $this->ApplicationService->IsDemoInstallation());
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
else
|
||||
@ -28,10 +29,12 @@ class SessionAuthMiddleware extends BaseMiddleware
|
||||
$sessionService = new SessionService();
|
||||
if ((!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName])) && $routeName !== 'login')
|
||||
{
|
||||
define('AUTHENTICATED', false);
|
||||
$response = $response->withRedirect($this->AppContainer->UrlManager->ConstructUrl('/login'));
|
||||
}
|
||||
else
|
||||
{
|
||||
define('AUTHENTICATED', $routeName !== 'login');
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ HTTP_USER }} <span class="caret"></span></a>
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">@if(AUTHENTICATED === true){{ HTTP_USER }}@endif <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="discrete-link logout-button" href="{{ $U('/logout') }}"><i class="fa fa-sign-out fa-fw"></i> {{ $L('Logout') }}</a>
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li class="divider logout-button"></li>
|
||||
<li>
|
||||
<a class="discrete-link" href="{{ $U('/manageapikeys') }}"><i class="fa fa-handshake-o fa-fw"></i> {{ $L('Manage API keys') }}</a>
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user