mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Applied PHP-CS-Fixer rules
This commit is contained in:
@@ -17,7 +17,7 @@ class ApiKeyAuthMiddleware extends AuthMiddleware
|
||||
$this->ApiKeyHeaderName = $this->AppContainer->get('ApiKeyHeaderName');
|
||||
}
|
||||
|
||||
function authenticate(Request $request)
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
if (!defined('GROCY_SHOW_AUTH_VIEWS'))
|
||||
{
|
||||
@@ -33,7 +33,7 @@ class ApiKeyAuthMiddleware extends AuthMiddleware
|
||||
|
||||
$apiKeyService = new ApiKeyService();
|
||||
|
||||
// First check of the API key in the configured header
|
||||
// First check of the API key in the configured header
|
||||
if (!$request->hasHeader($this->ApiKeyHeaderName) || !$apiKeyService->IsValidApiKey($request->getHeaderLine($this->ApiKeyHeaderName)))
|
||||
{
|
||||
$validApiKey = false;
|
||||
@@ -43,14 +43,14 @@ class ApiKeyAuthMiddleware extends AuthMiddleware
|
||||
$usedApiKey = $request->getHeaderLine($this->ApiKeyHeaderName);
|
||||
}
|
||||
|
||||
// Not recommended, but it's also possible to provide the API key via a query parameter (same name as the configured header)
|
||||
// Not recommended, but it's also possible to provide the API key via a query parameter (same name as the configured header)
|
||||
if (!$validApiKey && !empty($request->getQueryParam($this->ApiKeyHeaderName)) && $apiKeyService->IsValidApiKey($request->getQueryParam($this->ApiKeyHeaderName)))
|
||||
{
|
||||
$validApiKey = true;
|
||||
$usedApiKey = $request->getQueryParam($this->ApiKeyHeaderName);
|
||||
}
|
||||
|
||||
// Handling of special purpose API keys
|
||||
// Handling of special purpose API keys
|
||||
if (!$validApiKey)
|
||||
{
|
||||
if ($routeName === 'calendar-ical')
|
||||
@@ -59,21 +59,16 @@ class ApiKeyAuthMiddleware extends AuthMiddleware
|
||||
{
|
||||
$validApiKey = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($validApiKey)
|
||||
{
|
||||
return $apiKeyService->GetUserByApiKey($usedApiKey);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user