1
0
mirror of https://github.com/flarum/core.git synced 2025-10-11 23:14:29 +02:00

merges 5.5 and master into next-back

This commit is contained in:
Daniël Klabbers
2017-12-14 01:00:16 +01:00
104 changed files with 1723 additions and 1828 deletions

View File

@@ -20,10 +20,7 @@ use Zend\Stratigility\MiddlewareInterface;
class AuthenticateWithHeader implements MiddlewareInterface
{
/**
* @var string
*/
protected $prefix = 'Token ';
const TOKEN_PREFIX = 'Token ';
/**
* {@inheritdoc}
@@ -34,13 +31,14 @@ class AuthenticateWithHeader implements MiddlewareInterface
$parts = explode(';', $headerLine);
if (isset($parts[0]) && starts_with($parts[0], $this->prefix)) {
$id = substr($parts[0], strlen($this->prefix));
if (isset($parts[0]) && starts_with($parts[0], self::TOKEN_PREFIX)) {
$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)) {