Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Nov 15, 2023
1 parent 06fb99f commit 4458c5c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
17 changes: 13 additions & 4 deletions src/Api/CurrentUserAttributes.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/oauth.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\OAuth\Api;

use Flarum\Api\Serializer\CurrentUserSerializer;
Expand All @@ -13,18 +22,18 @@ class CurrentUserAttributes
* @var Cache
*/
protected $cache;

public function __construct(Cache $cache)
{
$this->cache = $cache;
}

public function __invoke(CurrentUserSerializer $serializer, User $user, array $attributes): array
{
$session = $serializer->getRequest()->getAttribute('session');

$attributes['loginProvider'] = $this->cache->get(AbstractOAuthController::SESSION_OAUTH2PROVIDER . '_' . $session->getId());
$attributes['loginProvider'] = $this->cache->get(AbstractOAuthController::SESSION_OAUTH2PROVIDER.'_'.$session->getId());

return $attributes;
}
}
17 changes: 13 additions & 4 deletions src/Listeners/HandleLogout.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/oauth.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\OAuth\Listeners;

use Flarum\Http\RequestUtil;
Expand All @@ -15,16 +24,16 @@ class HandleLogout
* @var Cache
*/
protected $cache;

public function __construct(Cache $cache)
{
$this->cache = $cache;
}

public function handle(LoggedOut $event)
{
$user = $event->user;

/** @var ServerRequestInterface|null $request */
$request = resolve('fof-oauth-request');

Expand All @@ -35,7 +44,7 @@ public function handle(LoggedOut $event)
/** @var Session $session */
$session = $request->getAttribute('session');

$this->cache->forget(AbstractOAuthController::SESSION_OAUTH2PROVIDER . '_' . $session->getId());
$this->cache->forget(AbstractOAuthController::SESSION_OAUTH2PROVIDER.'_'.$session->getId());
}
}
}
Expand Down
29 changes: 19 additions & 10 deletions src/Middleware/BindRequest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/oauth.
*
* Copyright (c) FriendsOfFlarum.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FoF\OAuth\Middleware;

use Illuminate\Contracts\Container\Container;
Expand All @@ -10,17 +19,17 @@

class ServerRequestMiddleware implements MiddlewareInterface
{
protected $container;
protected $container;

public function __construct(Container $container)
{
$this->container = $container;
}
public function __construct(Container $container)
{
$this->container = $container;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$this->container->instance('fof-oauth-request', $request);
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$this->container->instance('fof-oauth-request', $request);

return $handler->handle($request);
}
return $handler->handle($request);
}
}

0 comments on commit 4458c5c

Please sign in to comment.