Fixed error while checking an API key that doesn't exist

This commit is contained in:
Alejandro Celaya 2016-08-28 09:46:11 +02:00
parent 4bd67d5f98
commit a9f480ca99

View File

@ -66,7 +66,7 @@ class AuthenticateAction extends AbstractRestAction
// Authenticate using provided API key // Authenticate using provided API key
$apiKey = $this->apiKeyService->getByKey($authData['apiKey']); $apiKey = $this->apiKeyService->getByKey($authData['apiKey']);
if (! $apiKey->isValid()) { if (! isset($apiKey) || ! $apiKey->isValid()) {
return new JsonResponse([ return new JsonResponse([
'error' => RestUtils::INVALID_API_KEY_ERROR, 'error' => RestUtils::INVALID_API_KEY_ERROR,
'message' => $this->translator->translate('Provided API key does not exist or is invalid.'), 'message' => $this->translator->translate('Provided API key does not exist or is invalid.'),