Skip to content

Commit

Permalink
We shall only call the sso end session endpoint in case we still have…
Browse files Browse the repository at this point in the history
… the id_token. In some sceanrios the id_token is no longer known (expiry)
  • Loading branch information
DeepDiver1975 committed Feb 4, 2020
1 parent 6e80cdf commit 2f4a342
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ export function initVueAuthenticate (config) {
}
return null
},
getStoredUserObject () {
const storageString = sessionStorage.getItem('oc_oAuth' + mgr._userStoreKey)
if (storageString) {
const user = User.fromStorageString(storageString)
if (user) {
mgr.events.load(user, false)
return user
}
}
return null
},
isAuthenticated () {
return this.getToken() !== null
},
Expand Down
18 changes: 12 additions & 6 deletions src/store/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ const actions = {
// force redirect to login page after logout
router.push({ name: 'login' })
}
vueAuthInstance.logout()
.then(logoutFinalizer)
.catch(error => {
console.error(error)
logoutFinalizer()
})
// TODO: only call logout if we still have the id token
const u = vueAuthInstance.getStoredUserObject()
if (u && u.id_token) {
vueAuthInstance.logout()
.then(logoutFinalizer)
.catch(error => {
console.error(error)
logoutFinalizer()
})
} else {
logoutFinalizer()
}
},
initAuth (context, payload = { autoRedirect: false }) {
function init (client, token, doLogin = true) {
Expand Down

0 comments on commit 2f4a342

Please sign in to comment.