mirror of
https://github.com/flarum/core.git
synced 2025-10-18 18:26:07 +02:00
Refactor Flarum\Web and Flarum\Admin
- In order to be consistent with the Ember/LESS naming scheme, renamed Flarum\Web to Flarum\Forum. - Moved common classes into Flarum\Support so that Flarum\Admin doesn’t depend on Flarum\Forum. Also moved Actor into Flarum\Support as it doesn’t belong in the domain.
This commit is contained in:
28
src/Forum/Middleware/LoginWithCookie.php
Normal file
28
src/Forum/Middleware/LoginWithCookie.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php namespace Flarum\Forum\Middleware;
|
||||
|
||||
use Flarum\Support\Actor;
|
||||
use Flarum\Core\Models\AccessToken;
|
||||
use Auth;
|
||||
use Closure;
|
||||
|
||||
class LoginWithCookie
|
||||
{
|
||||
protected $actor;
|
||||
|
||||
public function __construct(Actor $actor)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
}
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (($token = $request->cookie('flarum_remember')) &&
|
||||
($accessToken = AccessToken::where('id', $token)->first())) {
|
||||
$this->actor->setUser($user = $accessToken->user);
|
||||
|
||||
$user->updateLastSeen()->save();
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user