Skip to content

Commit

Permalink
Disable caching of fof/oauth routes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaucau committed Dec 3, 2021
1 parent ec15ff1 commit 0b7b92b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Middleware/LSCacheMiddleware.php
Expand Up @@ -5,6 +5,7 @@
use Flarum\Http\RequestUtil;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Illuminate\Support\Str;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
Expand Down Expand Up @@ -35,6 +36,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface

$routeName = $request->getAttribute('routeName');

if (Str::startsWith($routeName, ['auth', 'fof-oauth'])) {
return $response->withHeader(LSCacheHeadersEnum::CACHE_CONTROL, 'no-cache');
}

if ($routeName === 'lscache.csrf') {
$sessionTTL = $this->config['lifetime'] * 60;
return $response->withHeader(LSCacheHeadersEnum::CACHE_CONTROL, "private,max-age=$sessionTTL");
Expand Down

0 comments on commit 0b7b92b

Please sign in to comment.