eCourt-Doc-Edit/web/app/pages/auth/callback.vue

43 lines
1.6 KiB
Vue
Raw Permalink Normal View History

2026-08-20 06:20:16 +07:00
<script setup lang="ts">
/** ปลายทางของ OIDC redirect — รับ code+state แลก token แล้วพากลับหน้าที่ login จาก (ทำงานฝั่ง client ทั้งหมด) */
const route = useRoute()
const { handleCallback, login } = useAuth()
const message = ref('กำลังตรวจสอบผลการเข้าสู่ระบบ…')
const failed = ref(false)
const busy = ref(true)
onMounted(async () => {
const result = await handleCallback(route.query)
if (result.ok) {
// replace เพื่อเช็ด ?code=...&state=... ออกจาก history
await navigateTo(result.returnTo ?? '/', { replace: true })
return
}
failed.value = true
busy.value = false
message.value = result.error ?? 'เข้าสู่ระบบไม่สำเร็จ'
})
</script>
<template>
<section class="mx-auto max-w-xl space-y-4 py-10 text-center">
<template v-if="busy">
2026-08-20 21:34:45 +07:00
<div class="flex items-center justify-center gap-3 text-sm text-muted">
<span class="spinner" />
2026-08-20 06:20:16 +07:00
{{ message }}
</div>
</template>
<template v-else>
<AlertBox type="error">{{ message }}</AlertBox>
2026-08-20 21:34:45 +07:00
<div class="flex flex-col-reverse justify-center gap-2 sm:flex-row">
<NuxtLink to="/" class="btn btn-secondary w-full sm:w-auto">กลับหน้าหลัก</NuxtLink>
<button type="button" class="btn btn-primary w-full sm:w-auto" @click="login()">
2026-08-20 06:20:16 +07:00
เข้าสู่ระบบใหม่
</button>
</div>
</template>
</section>
</template>