update merge dan set cookies
This commit is contained in:
@@ -72,10 +72,10 @@ export function useKeycloak() {
|
||||
const getProfile = () => profile.value;
|
||||
|
||||
// init on client automatically
|
||||
// onBeforeMount(() => {
|
||||
// // try check-sso silently
|
||||
// if (!initialized.value) initKeycloak("check-sso");
|
||||
// });
|
||||
onBeforeMount(() => {
|
||||
// try check-sso silently
|
||||
if (!initialized.value) initKeycloak("check-sso");
|
||||
});
|
||||
|
||||
const apiErrors = ref<Record<string, string>>({})
|
||||
const { login } = useUserStore()
|
||||
|
||||
@@ -2,7 +2,6 @@ import { getRequestURL, readBody, setCookie } from 'h3'
|
||||
|
||||
// Function to verify JWT token with the userinfo endpoint
|
||||
export default defineEventHandler(async (event) => {
|
||||
console.log("=================== MASUK FE SSO! ===================")
|
||||
const body = await readBody(event)
|
||||
const url = getRequestURL(event)
|
||||
const config = useRuntimeConfig()
|
||||
@@ -40,6 +39,22 @@ export default defineEventHandler(async (event) => {
|
||||
},
|
||||
})
|
||||
|
||||
if (resp.status === 200) {
|
||||
const data = await resp.json()
|
||||
|
||||
if (data?.data?.accessToken) {
|
||||
setCookie(event, 'authentication', data.data.accessToken, {
|
||||
path: '/',
|
||||
httpOnly: true,
|
||||
sameSite: 'strict',
|
||||
maxAge: 60 * 60 * 24,
|
||||
})
|
||||
|
||||
delete data.data.accessToken
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
return new Response(await resp.text(), {
|
||||
status: resp.status,
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user