diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index 7f4ff2807c..2629f15423 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -344,8 +344,7 @@ function showModal(_ref, modal, show) { function logoutAction(_ref) { localStorage.clear(); - _ref.props.navigate('/login'); - window.location.href = '/login'; + authenticationService.logout(true); return Promise.resolve(); } diff --git a/frontend/src/_services/authentication.service.js b/frontend/src/_services/authentication.service.js index cae8da7efe..0768f02d55 100644 --- a/frontend/src/_services/authentication.service.js +++ b/frontend/src/_services/authentication.service.js @@ -231,7 +231,7 @@ function resetPassword(params) { return fetch(`${config.apiUrl}/reset-password`, requestOptions).then(handleResponse); } -function logout() { +function logout(avoidRedirection = false) { const requestOptions = { method: 'GET', headers: authHeader(), @@ -242,16 +242,20 @@ function logout() { .then(handleResponseWithoutValidation) .then(() => { const loginPath = (window.public_config?.SUB_PATH || '/') + 'login'; - const pathname = window.public_config?.SUB_PATH - ? window.location.pathname.replace(window.public_config?.SUB_PATH, '') - : window.location.pathname; - window.location.href = - loginPath + - `?redirectTo=${ - !pathname.includes('integrations') - ? excludeWorkspaceIdFromURL(pathname) - : `${pathname.indexOf('/') === 0 ? '' : '/'}${pathname}` - }`; + if (avoidRedirection) { + window.location.href = loginPath; + } else { + const pathname = window.public_config?.SUB_PATH + ? window.location.pathname.replace(window.public_config?.SUB_PATH, '') + : window.location.pathname; + window.location.href = + loginPath + + `?redirectTo=${ + !pathname.includes('integrations') + ? excludeWorkspaceIdFromURL(pathname) + : `${pathname.indexOf('/') === 0 ? '' : '/'}${pathname}` + }`; + } }) .catch(() => { authenticationService.updateCurrentSession({