1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 17:51:24 +02:00

Add the ApiKey model as a request attribute

This commit is contained in:
Toby Zerner
2017-10-05 12:26:05 +10:30
parent 8ccfb1aac6
commit 096e552c74

View File

@@ -35,9 +35,10 @@ class AuthenticateWithHeader implements MiddlewareInterface
$id = substr($parts[0], strlen(self::TOKEN_PREFIX)); $id = substr($parts[0], strlen(self::TOKEN_PREFIX));
if (isset($parts[1])) { if (isset($parts[1])) {
if (ApiKey::find($id)) { if ($key = ApiKey::find($id)) {
$actor = $this->getUser($parts[1]); $actor = $this->getUser($parts[1]);
$request = $request->withAttribute('apiKey', $key);
$request = $request->withAttribute('bypassFloodgate', true); $request = $request->withAttribute('bypassFloodgate', true);
} }
} elseif ($token = AccessToken::find($id)) { } elseif ($token = AccessToken::find($id)) {