Created
June 25, 2021 18:16
-
-
Save kingluddite/9fc9117e3f541c38f7126005592086b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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