Skip to content

Commit

Permalink
wip: Logout raises an error #741
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Jul 11, 2023
1 parent 6b43de6 commit 7afe696
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/client/utils/utils.session.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export async function register (user) {
}

export async function logout () {
await api.logout()
try {
await api.logout()
} catch (error) {
logger.warn(`[KDK] logout session failed: ${error}`)
await api.authentication.removeAccessToken()
}
Store.set('user', null)
}

Expand All @@ -34,10 +39,7 @@ export async function restoreSession () {
Store.set('user', user)
} catch (error) {
// This ensure an old token is not kept when the user has been deleted
if (error.code === 404) {
await api.authentication.removeAccessToken()
await logout()
}
if (error.code === 404) await logout()
// Rethrow for caller to handle
throw error
}
Expand All @@ -50,7 +52,7 @@ export async function updateAbilities () {
const abilities = await defineAbilities(user, api)
Store.set('user.abilities', abilities)
if (abilities) {
logger.debug('New user abilities: ', abilities.rules)
logger.debug('[KDK] New user abilities: ', abilities.rules)
}
}

Expand Down

0 comments on commit 7afe696

Please # to comment.