update
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
export default defineNuxtRouteMiddleware((to) => {
|
||||
import { useKeycloak } from "~/composables/useKeycloack"
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
if (to.meta.public) return
|
||||
|
||||
const { $pinia } = useNuxtApp()
|
||||
const oidc = useOidcAuth();
|
||||
|
||||
const { initKeycloak, isAuthenticated} = useKeycloak(); // global composable
|
||||
await initKeycloak("check-sso");
|
||||
|
||||
if (import.meta.client) {
|
||||
const userStore = useUserStore($pinia)
|
||||
if (!userStore.isAuthenticated && !oidc.loggedIn) {
|
||||
if (!userStore.isAuthenticated && !isAuthenticated.value) {
|
||||
// await login({ redirectUri: window.location.origin + to.fullPath });
|
||||
return navigateTo('/auth/login')
|
||||
// oidc.login('dev');
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user