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

Massive refactor

- Use contextual namespaces within Flarum\Core
- Clean up and docblock everything
- Refactor Activity/Notification blueprint stuff
- Refactor Formatter stuff
- Refactor Search stuff
- Upgrade to JSON-API 1.0
- Removed “addedPosts” and “removedPosts” relationships from discussion
API. This was used for adding/removing event posts after renaming a
discussion etc. Instead we should make an additional request to get all
new posts

Todo:
- Fix Extenders and extensions
- Get rid of repository interfaces
- Fix other bugs I’ve inevitably introduced
This commit is contained in:
Toby Zerner
2015-07-04 12:24:48 +09:30
parent 12dd550a14
commit a74b40fe47
324 changed files with 6443 additions and 4197 deletions

View File

@@ -1,7 +1,7 @@
<?php namespace Flarum\Api\Middleware;
use Flarum\Core\Models\AccessToken;
use Flarum\Support\Actor;
use Flarum\Api\AccessToken;
use Illuminate\Contracts\Container\Container;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Stratigility\MiddlewareInterface;
@@ -9,20 +9,21 @@ use Zend\Stratigility\MiddlewareInterface;
class LoginWithHeader implements MiddlewareInterface
{
/**
* @var Actor
* @var Container
*/
protected $actor;
protected $app;
/**
* @var string
*/
protected $prefix = 'Token ';
// @todo rather than using a singleton, we should have our own HTTP
// Request class and store the actor on that? somehow?
public function __construct(Actor $actor)
/**
* @param Container $app
*/
public function __construct(Container $app)
{
$this->actor = $actor;
$this->app = $app;
}
/**
@@ -35,7 +36,7 @@ class LoginWithHeader implements MiddlewareInterface
($token = substr($header, strlen($this->prefix))) &&
($accessToken = AccessToken::where('id', $token)->first())
) {
$this->actor->setUser($user = $accessToken->user);
$this->app->instance('flarum.actor', $user = $accessToken->user);
$user->updateLastSeen()->save();
}