Add the ApiKey model as a request attribute

This commit is contained in:
Toby Zerner 2017-10-05 12:26:05 +10:30
parent 09f98a5cbb
commit 8c782a00e9

View File

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