mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
fix(cache): trigger page reload on logout (#7407)
When portainer is restarted the user's session is invalidated and as soon as they start clicking around they will be logged out. This PR does two additional things when this happens. 1) We trigger a browser page reload which will force the client the grab the latest version of our js, css, etc. Previously if a user updated portainer, but never clicked the browser's refresh button they would never see new css changes. 2) We also set "cache-control no-cache" on the index.html header. Since portainer is an SPA and the the index.html is very small it makes sense to avoid letting the browser cache it so that the user is always given the latest version when the above reload is triggered.
This commit is contained in:
parent
69a824c25b
commit
7b806cf586
2 changed files with 4 additions and 0 deletions
|
@ -5,6 +5,9 @@
|
|||
<title>Portainer</title>
|
||||
<meta name="description" content="" />
|
||||
<meta name="author" content="<%= author %>" />
|
||||
<meta http-equiv="cache-control" content="no-cache" />
|
||||
<meta http-equiv="expires" content="0" />
|
||||
<meta http-equiv="pragma" content="no-cache" />
|
||||
<base id="base" />
|
||||
<script>
|
||||
if (window.origin == 'file://') {
|
||||
|
|
|
@ -22,6 +22,7 @@ async function initAuthentication(authManager, Authentication, $rootScope, $stat
|
|||
$rootScope.$on('unauthenticated', function (event, data) {
|
||||
if (!_.includes(data.config.url, '/v2/') && !_.includes(data.config.url, '/api/v4/') && isTransitionRequiresAuthentication($state.transition)) {
|
||||
$state.go('portainer.logout', { error: 'Your session has expired' });
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue