Files
simrsx-fe/app/pages/auth/sso.vue
2025-11-25 11:06:51 +07:00

31 lines
918 B
Vue

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useKeycloak } from "~/composables/useKeycloack"
const error = ref<string | null>(null)
const { initKeycloak, isAuthenticated, getResponse } = useKeycloak()
onMounted(async () => {
try {
// Initialize Keycloak with login-required to ensure tokens set (Keycloak will process the code/state returned)
await initKeycloak('login-required')
// small delay to allow token propagation
if (isAuthenticated.value) {
await getResponse()
} else {
return navigateTo('/auth/login')
}
} catch (err: any) {
error.value = err?.message || String(err)
}
})
</script>
<template>
<div style="max-width:720px;margin:40px auto">
<h2>Processing login...</h2>
<p v-if="error">Terjadi error: {{ error }}</p>
<p v-else>Mohon tunggu, sedang memproses otentikasi dan mengarahkan Anda ...</p>
</div>
</template>