File tree Expand file tree Collapse file tree 1 file changed +14
-18
lines changed Expand file tree Collapse file tree 1 file changed +14
-18
lines changed Original file line number Diff line number Diff line change @@ -45,25 +45,21 @@ value and then a User object is created::
45
45
46
46
public function createToken(Request $request, $providerKey)
47
47
{
48
- if ($request->query->has('apikey')) {
49
- return new PreAuthenticatedToken(
50
- 'anon.',
51
- $request->query->get('apikey'),
52
- $providerKey
53
- );
54
- }
55
- else if($request->request->has('apikey'))
56
- {
57
- return new PreAuthenticatedToken(
58
- 'anon.',
59
- $request->request->get('apikey'),
60
- $providerKey
61
- );
62
- }
63
- else
64
- {
48
+ // look for an apikey query parameter
49
+ $apiKey = $request->query->get('apikey');
50
+
51
+ // or if you want to use an "apikey" header, then do something like this:
52
+ // $apiKey = $request->headers->get('apikey');
53
+
54
+ if (!$apiKey) {
65
55
throw new BadCredentialsException('No API key found');
66
- }
56
+ }
57
+
58
+ return new PreAuthenticatedToken(
59
+ 'anon.',
60
+ $apiKey,
61
+ $providerKey
62
+ );
67
63
}
68
64
69
65
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
You can’t perform that action at this time.
0 commit comments