8000 Update api_key_authentication.rst - POST Method · symfony/symfony-docs@59e4bd4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59e4bd4

Browse files
BourotBenjaminwouterj
authored andcommitted
Update api_key_authentication.rst - POST Method
1 parent 1f14a0e commit 59e4bd4

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

cookbook/security/api_key_authentication.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,25 @@ value and then a User object is created::
4545

4646
public function createToken(Request $request, $providerKey)
4747
{
48-
if (!$request->query->has('apikey')) {
49-
throw new BadCredentialsException('No API key found');
48+
if ($request->query->has('apikey')) {
49+
return new PreAuthenticatedToken(
50+
'anon.',
51+
$request->query->get('apikey'),
52+
$providerKey
53+
);
5054
}
51-
52-
return new PreAuthenticatedToken(
53-
'anon.',
54-
$request->query->get('apikey'),
55-
$providerKey
56-
);
55+
else if($request->request->has('apikey'))
56+
{
57+
return new Pr 7A0F eAuthenticatedToken(
58+
'anon.',
59+
$request->request->get('apikey'),
60+
$providerKey
61+
);
62+
}
63+
else
64+
{
65+
throw new BadCredentialsException('No API key found');
66+
}
5767
}
5868

5969
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)

0 commit comments

Comments
 (0)
0