Skip to content

Best Practices for Keycloak Initialization Before Vue Router Guards #15

Closed Answered by JoseGoncalves
loic-bellinger asked this question in Q&A
Discussion options

You must be logged in to vote

Using check-sso you can try something like the following (not tested):

<script setup>
import { watch } from 'vue';
import { useKeycloak } from '@josempgon/vue-keycloak';

const { isAuthenticated, isPending, keycloak } = useKeycloak();

watch(isPending, pending => {
	if (!pending) keycloak.value.login();
});
</script>

<template>
	<div v-if="isAuthenticated">
		<router-view />
	</div>
	<div v-else>
              <-- progress component !-->
	</div>
</template>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@loic-bellinger
Comment options

@JoseGoncalves
Comment options

Answer selected by loic-bellinger
@loic-bellinger
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants