1
0
mirror of https://github.com/flarum/core.git synced 2025-10-18 18:26:07 +02:00

Remove Middleware suffix

This commit is contained in:
Toby Zerner
2015-02-26 12:45:44 +10:30
parent f2fe0a2e1d
commit b4f3148e30
4 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,29 @@
<?php namespace Flarum\Api\Middleware;
use Flarum\Core\Models\AccessToken;
use Flarum\Core\Support\Actor;
use Closure;
class LoginWithHeader
{
protected $actor;
protected $prefix = 'Token ';
public function __construct(Actor $actor)
{
$this->actor = $actor;
}
public function handle($request, Closure $next)
{
$header = $request->headers->get('authorization');
if (starts_with($header, $this->prefix) &&
($token = substr($header, strlen($this->prefix))) &&
($accessToken = AccessToken::where('id', $token)->first())) {
$this->actor->setUser($accessToken->user);
}
return $next($request);
}
}