Skip to content
Permalink
Browse files

refactor: lets use constant in credential array

  • Loading branch information...
tarlepp committed Jun 2, 2019
1 parent 8f452a0 commit 791a4cebc9fc5965c9dc5b64ae20847895556a44
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/Security/Authenticator/ApiKeyAuthenticator.php
@@ -33,6 +33,8 @@
*/
class ApiKeyAuthenticator extends AbstractGuardAuthenticator
{
private const CREDENTIAL_KEY = 'token';
/**
* @var ApiKeyUserProvider
*/
@@ -132,7 +134,7 @@ public function getCredentials(Request $request)
if (count($matches) > 0) {
$output = [
'token' => $matches[1],
self::CREDENTIAL_KEY => $matches[1],
];
}
@@ -156,7 +158,7 @@ public function getCredentials(Request $request)
*/
public function getUser($credentials, UserProviderInterface $userProvider): ?ApiKeyUserInterface
{
$apiToken = is_array($credentials) ? $credentials['token'] ?? null : null;
$apiToken = is_array($credentials) ? $credentials[self::CREDENTIAL_KEY] ?? null : null;
if ($apiToken === null) {
return null;
@@ -183,7 +185,7 @@ public function getUser($credentials, UserProviderInterface $userProvider): ?Api
*/
public function checkCredentials($credentials, UserInterface $user): bool
{
$apiToken = is_array($credentials) ? $credentials['token'] ?? null : null;
$apiToken = is_array($credentials) ? $credentials[self::CREDENTIAL_KEY] ?? null : null;
if ($apiToken === null) {
throw new AuthenticationException('Invalid token');

0 comments on commit 791a4ce

Please sign in to comment.
You can’t perform that action at this time.