38 lines
1.1 KiB
Vue
38 lines
1.1 KiB
Vue
<script setup lang="ts">
|
|
import { onMounted } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { apiErrorMessage } from '../api/http'
|
|
import { useAuthStore } from '../stores/auth'
|
|
import { safeAuthRedirect } from '../utils/navigate'
|
|
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const auth = useAuthStore()
|
|
const { t } = useI18n()
|
|
|
|
onMounted(async () => {
|
|
const code = String(route.query.code ?? '')
|
|
if (!code) {
|
|
await router.replace({ name: 'login', query: { ssoError: 'authentication_failed' } })
|
|
return
|
|
}
|
|
|
|
try {
|
|
await auth.exchangeSso(code)
|
|
await router.replace(safeAuthRedirect(route.query.redirect))
|
|
} catch (error) {
|
|
ElMessage.error(apiErrorMessage(error))
|
|
await router.replace({ name: 'login', query: { ssoError: 'authentication_failed' } })
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<main class="sso-callback-page">
|
|
<el-icon class="is-loading" :size="34"><Loading /></el-icon>
|
|
<h1>{{ t('auth.sso.completing') }}</h1>
|
|
<p>{{ t('auth.sso.completingHint') }}</p>
|
|
</main>
|
|
</template>
|