fix(xo-web): fix signout

Introduced by 281a1cc54
This commit is contained in:
Julien Fontanet 2022-09-02 18:45:10 +02:00
parent 6cbce81faa
commit 37cdbc19ef

View File

@ -75,13 +75,19 @@ export const isVmRunning = vm => vm && vm.power_state === 'Running'
// ===================================================================
export const signOut = () => {
const reload = () => {
// prevent automatic reconnection
xo.removeListener('closed', connect)
window.location.reload(true)
}
export const signOut = () => {
cookies.remove('token')
reload()
}
export const connect = () => {
xo.open(createBackoff()).catch(error => {
logError(error, 'failed to connect to xo-server')
@ -91,7 +97,7 @@ export const connect = () => {
const xo = invoke(() => {
const token = cookies.get('token')
if (!token) {
signOut()
reload()
throw new Error('no valid token')
}
@ -99,7 +105,7 @@ const xo = invoke(() => {
credentials: { token },
})
xo.on('authenticationFailure', signOut)
xo.on('authenticationFailure', reload)
xo.on('scheduledAttempt', ({ delay }) => {
console.warn('next attempt in %s ms', delay)
})