do not logout when trying to reconnect to the server since the session should still be valid

This commit is contained in:
axolotle 2023-12-29 17:53:53 +01:00
parent 8db7691fe2
commit 1d892350cd
4 changed files with 14 additions and 11 deletions

View file

@ -217,12 +217,12 @@ export default {
const api = this
function reconnect(n) {
api
.get('logout', {}, { key: 'reconnecting' })
store
.dispatch('GET_YUNOHOST_INFOS')
.then(resolve)
.catch((err) => {
if (err.name === 'APIUnauthorizedError') {
resolve()
reject(err)
} else if (n < 1) {
reject(err)
} else {

View file

@ -31,7 +31,7 @@
"unknown": "Connection with the server has been closed for unknown reasons.",
"upgrade_system": "Connection with the server has been closed due to YunoHost upgrade. Waiting for the server to be reachable again…"
},
"success": "The server is now reachable! You can try to login",
"session_expired": "The server is now reachable! But it looks like your session expired, please login.",
"title": "Trying to communicate with the server…"
}
},

View file

@ -179,10 +179,9 @@ export default {
return api.get('logout')
},
TRY_TO_RECONNECT({ commit, dispatch }, args = {}) {
TRY_TO_RECONNECT({ commit }, args = {}) {
// FIXME This is very ugly arguments forwarding, will use proper component way of doing this when switching to Vue 3 (teleport)
commit('SET_RECONNECTING', args)
dispatch('RESET_CONNECTED')
},
GET_YUNOHOST_INFOS({ commit }) {

View file

@ -28,8 +28,8 @@
</div>
</template>
<template v-if="status === 'success'">
<BAlert variant="success" v-t="'api.reconnecting.success'" />
<template v-if="status === 'expired'">
<BAlert variant="success" v-t="'api.reconnecting.session_expired'" />
<LoginView force-reload />
</template>
@ -66,10 +66,14 @@ export default {
api
.tryToReconnect({ ...this.reconnecting, initialDelay })
.then(() => {
this.status = 'success'
this.$store.commit('SET_RECONNECTING', null)
})
.catch(() => {
this.status = 'failed'
.catch((err) => {
if (err.name === 'APIUnauthorizedError') {
this.status = 'expired'
} else {
this.status = 'failed'
}
})
},
},