Skip to content

Instantly share code, notes, and snippets.

@kingluddite
Created June 25, 2021 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingluddite/9fc9117e3f541c38f7126005592086b5 to your computer and use it in GitHub Desktop.
Save kingluddite/9fc9117e3f541c38f7126005592086b5 to your computer and use it in GitHub Desktop.
<template>
<div id="home">
<div v-if="this.$parent.authenticated">
<button v-on:click="logout()">
Logout
</button>
</div>
</div>
</template>
<script>
const POST_LOGOUT_REDIRECT_URI = '/'
const ISSUER = 'https://{yourOktaDomain}/oauth2/default'
export default {
name: 'home',
methods: {
async logout () {
// Read idToken before local session is cleared
const idToken = await this.$auth.getIdToken()
// Clear local session
await this.$auth.logout()
// Clear remote session
window.location.href = `${ISSUER}/v1/logout?id_token_hint=${idToken}&post_logout_redirect_uri=${POST_LOGOUT_REDIRECT_URI}`
},
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment