Fixed logout event issue on editor (#6019)

This commit is contained in:
Kavin Venkatachalam 2023-04-24 17:40:58 +05:30 committed by GitHub
parent 8e65eabb70
commit b82c4c7044
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View file

@ -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();
}

View file

@ -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({