update
This commit is contained in:
@@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppAuthLogin :schema="loginSchema" :is-loading="isLoading" @submit="onSubmit" @sso="onSSO" />
|
||||
<AppAuthLogin :schema="loginSchema" :is-loading="isLoading" @submit="onSubmit" @sso="onSSO" @response="onResponseSSO" />
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user