Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
disable caching headers in AbstractTheme if user is logged in
  • Loading branch information
Guite committed Oct 4, 2021
1 parent d5909c9 commit f085bbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-3.0.md
Expand Up @@ -10,6 +10,7 @@
- [CoreBundle] Add `flex-wrap` class to pagination for responsive behaviour ([bs#23504](https://github.com/twbs/bootstrap/issues/23504)).
- [Blocks] Strip script tags from XSLT block stylesheets.
- [Categories] Sanitize context menu in admin category list.
- [Extensions] Disable caching headers in `AbstractTheme` if user is logged in.
- [Theme] Fix resolving assets location on Windows if Zikula is installed in a sub directory (#4480).
- [Permissions] Correctly handle non-existing username during permission testing.
- [Users] Dispatch `UserPostLoginFailureEvent` after login failure as expected.
Expand Down
11 changes: 10 additions & 1 deletion src/system/ExtensionsModule/AbstractTheme.php
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\Yaml\Yaml;
use Twig\Environment;
use Zikula\ExtensionsModule\Api\VariableApi;
use Zikula\UsersModule\Api\CurrentUserApi;

abstract class AbstractTheme extends AbstractExtension
{
Expand Down Expand Up @@ -75,8 +76,16 @@ public function generateThemedResponse(
]);

$content = $twig->render('@' . $this->name . '/' . $template, ['maincontent' => $content]);
$response = new Response($content);

return new Response($content);
$isLoggedIn = $this->getContainer()->get(CurrentUserApi::class)->isLoggedIn();
if ($isLoggedIn) {
$response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
$response->headers->set('Pragma','no-cache');
$response->headers->set('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
}

return $response;
}

/**
Expand Down

0 comments on commit f085bbd

Please sign in to comment.