From 70deba50bab28c9e8a5cf7fb6a1db535d3c60058 Mon Sep 17 00:00:00 2001 From: Matt Hook Date: Tue, 30 Jan 2024 10:39:12 +1300 Subject: [PATCH] fix(kube): clear kube cache on login/logout [EE-6620] (#11026) --- app/portainer/views/auth/authController.js | 4 ++++ app/portainer/views/logout/logoutController.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/portainer/views/auth/authController.js b/app/portainer/views/auth/authController.js index a03e19109..9004d2cde 100644 --- a/app/portainer/views/auth/authController.js +++ b/app/portainer/views/auth/authController.js @@ -1,6 +1,7 @@ import angular from 'angular'; import uuidv4 from 'uuid/v4'; import { getEnvironments } from '@/react/portainer/environments/environment.service'; +import { dispatchCacheRefreshEvent } from '@/portainer/services/http-request.helper'; class AuthenticationController { /* @ngInject */ @@ -261,6 +262,9 @@ class AuthenticationController { this.LocalStorage.cleanLogoutReason(); } + // always clear the kubernetes cache on login + dispatchCacheRefreshEvent(); + if (this.Authentication.isAuthenticated()) { await this.postLoginSteps(); } diff --git a/app/portainer/views/logout/logoutController.js b/app/portainer/views/logout/logoutController.js index 244081c07..5369121d6 100644 --- a/app/portainer/views/logout/logoutController.js +++ b/app/portainer/views/logout/logoutController.js @@ -1,4 +1,5 @@ import angular from 'angular'; +import { dispatchCacheRefreshEvent } from '@/portainer/services/http-request.helper'; class LogoutController { /* @ngInject */ @@ -30,6 +31,9 @@ class LogoutController { try { await this.Authentication.logout(); } finally { + // always clear the kubernetes cache + dispatchCacheRefreshEvent(); + this.LocalStorage.storeLogoutReason(error); if (settings.OAuthLogoutURI && this.Authentication.getUserDetails().ID !== 1) { this.$window.location.href = settings.OAuthLogoutURI;