mirror of
https://github.com/grocy/grocy.git
synced 2026-10-17 05:14:20 +02:00
Reviewed latest middleware optimizations
This commit is contained in:
parent
d941daae42
commit
4732f4a186
|
|
@ -13,14 +13,14 @@ class DefaultAuthMiddleware extends BaseAuthMiddleware
|
|||
if ($this->IsApiRoute)
|
||||
{
|
||||
// Session cookie or API Key is ok
|
||||
$auth = new ApiKeyAuthMiddleware($this->AppContainer, $this->ResponseFactory);
|
||||
$auth = new SessionAuthMiddleware($this->AppContainer, $this->ResponseFactory);
|
||||
$user = $auth->AuthenticateRequest($request);
|
||||
if ($user !== null)
|
||||
{
|
||||
return $user;
|
||||
}
|
||||
|
||||
$auth = new SessionAuthMiddleware($this->AppContainer, $this->ResponseFactory);
|
||||
$auth = new ApiKeyAuthMiddleware($this->AppContainer, $this->ResponseFactory);
|
||||
$user = $auth->AuthenticateRequest($request);
|
||||
return $user;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ReverseProxyAuthMiddleware extends BaseAuthMiddleware
|
|||
{
|
||||
define('GROCY_EXTERNALLY_MANAGED_AUTHENTICATION', true);
|
||||
|
||||
// When the reverse proxy is configured to be bypassed for API routes, try to use regular ApiKeyAuth
|
||||
// Try to use regular API Key authentiaction (applies when the reverse proxy is configured to be bypassed for API routes)
|
||||
if ($this->IsApiRoute)
|
||||
{
|
||||
$auth = new ApiKeyAuthMiddleware($this->AppContainer, $this->ResponseFactory);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class BaseMiddleware
|
|||
$this->ApplicationService = ApplicationService::GetInstance();
|
||||
}
|
||||
|
||||
protected $AppContainer;
|
||||
protected $ResponseFactory;
|
||||
protected $ApplicationService;
|
||||
protected Container $AppContainer;
|
||||
protected ResponseFactoryInterface $ResponseFactory;
|
||||
protected ApplicationService $ApplicationService;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class LocaleMiddleware extends BaseMiddleware
|
|||
|
||||
private function GetLocale(Request $request)
|
||||
{
|
||||
// demo and prerelease modes are fixed to the default locale
|
||||
// Demo and Prerelease modes are fixed to the default locale
|
||||
if (GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
|
||||
{
|
||||
return GROCY_DEFAULT_LOCALE;
|
||||
|
|
@ -28,7 +28,6 @@ class LocaleMiddleware extends BaseMiddleware
|
|||
if (defined('GROCY_AUTHENTICATED') && GROCY_AUTHENTICATED)
|
||||
{
|
||||
$locale = UsersService::GetInstance()->GetUserSetting(GROCY_USER_ID, 'locale');
|
||||
|
||||
if (isset($locale) && !empty($locale))
|
||||
{
|
||||
if (in_array($locale, scandir(__DIR__ . '/../localization')))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user