mirror of
https://github.com/portainer/portainer.git
synced 2026-08-07 09:54:49 +00:00
fix(logout): stop unathenticated request loop on logout [R8S-1193] (#3261)
This commit is contained in:
committed by
GitHub
parent
b7d4cfbd09
commit
841442c19c
@@ -125,13 +125,17 @@ export function agentInterceptor(config: InternalAxiosRequestConfig) {
|
||||
axios.interceptors.request.use(dockerMaxAPIVersionInterceptor);
|
||||
axios.interceptors.request.use(agentInterceptor);
|
||||
|
||||
let isRedirectingToLogout = false;
|
||||
|
||||
axios.interceptors.response.use(undefined, (error) => {
|
||||
if (
|
||||
error.response?.status === 401 &&
|
||||
!error.config.url.includes('/v2/') && // docker proxy through agent
|
||||
!error.config.url.includes('/api/v4/') && // gitlab proxy
|
||||
!isRedirectingToLogout &&
|
||||
isTransitionRequiresAuthentication()
|
||||
) {
|
||||
isRedirectingToLogout = true;
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('Unauthorized request, logging out');
|
||||
window.location.hash = '/logout';
|
||||
|
||||
Reference in New Issue
Block a user