From bbdaeee304854604d5198cbdb6295afd11e7b9ba Mon Sep 17 00:00:00 2001 From: ari Date: Thu, 20 Nov 2025 16:25:35 +0700 Subject: [PATCH] update --- app/components/app/auth/login.vue | 12 +++++++ app/components/content/auth/login.vue | 50 ++++++++++++++++----------- app/pages/auth/sso.vue | 13 +++++++ 3 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 app/pages/auth/sso.vue diff --git a/app/components/app/auth/login.vue b/app/components/app/auth/login.vue index d7f549dd..7131daf2 100644 --- a/app/components/app/auth/login.vue +++ b/app/components/app/auth/login.vue @@ -14,6 +14,7 @@ const props = defineProps() const emit = defineEmits<{ submit: [data: any] sso: [] + response: [state: string] }>() const { handleSubmit, defineField, errors, meta } = useForm({ @@ -45,6 +46,14 @@ const onSSO = (async () => { } }); +const test = useRoute() +const responseSSO = test.hash + +if (responseSSO != null && responseSSO != '') { + console.log("Getting Response SSO...") + await emit('response', responseSSO) +} + diff --git a/app/components/content/auth/login.vue b/app/components/content/auth/login.vue index 27aeef5f..23ab2316 100644 --- a/app/components/content/auth/login.vue +++ b/app/components/content/auth/login.vue @@ -60,29 +60,11 @@ async function onSSO() { }); try { - await keycloak.init({ onLoad: 'login-required' }); // Or 'login-required' + const authenticatedResult = await keycloak.init({ onLoad: 'login-required' }); // Or 'login-required' + // seelah line ini aku mek paham logic e tapi faktane dunno const nuxtApp = useNuxtApp() nuxtApp.provide('keycloak', keycloak); - const result = await xfetch('/api/v1/authentication/login-fes', 'POST', { - data: keycloak, - }) - - if (result.success) { - const { data: rawdata, meta } = result.body - if (meta.status === 'verified') { - login(rawdata) - navigateTo('/') - } - } else { - if (result.errors) { - Object.entries(result.errors).forEach( - ([field, errorInfo]: [string, any]) => (apiErrors.value[field] = errorInfo.message), - ) - } else { - apiErrors.value.general = result.error?.message || result.message || 'Login failed' - } - } } catch (error) { console.error('Keycloak initialization failed:', error); } @@ -144,10 +126,36 @@ async function onSSO() { // external: true // }) } + +async function onResponseSSO(authenticatedResult: string) { + console.log("=================== onto login fes!!! ===================") + console.log(authenticatedResult) + if (authenticatedResult) { + const result = await xfetch('/api/v1/authentication/login-fes', 'POST', { + data: authenticatedResult, + }) + + if (result.success) { + const { data: rawdata, meta } = result.body + if (meta.status === 'verified') { + login(rawdata) + navigateTo('/') + } + } else { + if (result.errors) { + Object.entries(result.errors).forEach( + ([field, errorInfo]: [string, any]) => (apiErrors.value[field] = errorInfo.message), + ) + } else { + apiErrors.value.general = result.error?.message || result.message || 'Login failed' + } + } + } +} diff --git a/app/pages/auth/sso.vue b/app/pages/auth/sso.vue new file mode 100644 index 00000000..f2b21099 --- /dev/null +++ b/app/pages/auth/sso.vue @@ -0,0 +1,13 @@ + + +