add sesion belum fix
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { UserIcon, MailIcon, ListCheckIcon } from 'vue-tabler-icons';
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const { session, refresh, update, reset, overwrite } = await useSession()
|
||||
|
||||
const user_profile = useCookie('user_profile');
|
||||
const user_token = useCookie('user_token');
|
||||
const logout = async () => {
|
||||
window.location.href = `${runtimeConfig.public.keycloakUrl}/realms/${runtimeConfig.public.keycloakRealm}/protocol/openid-connect/logout?client_id=${runtimeConfig.public.keycloakClient}&post_logout_redirect_uri=http://localhost:3000`;
|
||||
user_token.value = null;
|
||||
await reset()
|
||||
localStorage.removeItem('userProfile')
|
||||
localStorage.removeItem('sidebarItems')
|
||||
navigateTo('/auth/login')
|
||||
|
||||
+8
-3
@@ -13,7 +13,7 @@ useHead({
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const { session, refresh, update, reset, overwrite } = await useSession()
|
||||
const { $encodeBase64, $decodeBase64 } = useNuxtApp();
|
||||
const sidebarMenu = ref('');
|
||||
const sessionState = ref('');
|
||||
@@ -47,13 +47,15 @@ const response = $fetch(`${issuer.value}/protocol/openid-connect/token`, {
|
||||
const idMongose = response.idMongose
|
||||
const encodeProfile = $encodeBase64(JSON.stringify(response))
|
||||
localStorage.setItem('userProfile', encodeProfile)
|
||||
cobaSetProfile.value.push(encodeProfile)
|
||||
$fetch(`/api/sidebarItem`, {
|
||||
// cobaSetProfile.value.push(encodeProfile)
|
||||
$fetch(`/api/auth/sidebarItem`, {
|
||||
method: 'POST',
|
||||
body: { key: idMongose }
|
||||
})
|
||||
.then((response) => {
|
||||
localStorage.setItem('sidebarItems', $encodeBase64(JSON.stringify(response)))
|
||||
update({ 'user_login': response })
|
||||
// overwrite({ 'sidebarItems': response })
|
||||
sidebarMenu.value = response.items
|
||||
}).catch((err) => {
|
||||
loadSidebarItemLocalStorage()
|
||||
@@ -74,7 +76,10 @@ const response = $fetch(`${issuer.value}/protocol/openid-connect/token`, {
|
||||
|
||||
function loadSidebarItemLocalStorage() {
|
||||
const as = JSON.parse($decodeBase64(localStorage.getItem('sidebarItems')))
|
||||
console.log(session.value)
|
||||
console.log('sdadsd')
|
||||
sidebarMenu.value = as.items
|
||||
// sidebarMenu.value = session.value.user_login.items
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
+10
-6
@@ -1,7 +1,7 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
export default defineNuxtConfig({
|
||||
ssr: false,
|
||||
|
||||
devtools: { enabled: true },
|
||||
typescript: {
|
||||
shim: false
|
||||
},
|
||||
@@ -26,7 +26,10 @@ export default defineNuxtConfig({
|
||||
},
|
||||
modules: [
|
||||
'@vueform/nuxt',
|
||||
'@sidebase/nuxt-auth'
|
||||
'@pinia/nuxt',
|
||||
'@sidebase/nuxt-auth',
|
||||
'nuxt-mongoose',
|
||||
'@sidebase/nuxt-session',
|
||||
],
|
||||
// auth: {
|
||||
// isEnabled: true,
|
||||
@@ -47,9 +50,9 @@ export default defineNuxtConfig({
|
||||
// },
|
||||
|
||||
runtimeConfig: {
|
||||
auth: {
|
||||
origin: process.env.NUXT_AUTH_ORIGIN || 'http://localhost:3000'
|
||||
},
|
||||
// auth: {
|
||||
// origin: process.env.NUXT_AUTH_ORIGIN || 'http://localhost:3000'
|
||||
// },
|
||||
public: {
|
||||
keycloakUrl: 'https://auth.rssa.top',
|
||||
keycloakRealm: 'sandbox',
|
||||
@@ -57,8 +60,9 @@ export default defineNuxtConfig({
|
||||
keycloakSecretKey: '32HslhZ8Hn97SsbxcmowhXvmNZ9cPGNE',
|
||||
keycloakRedirectURI: 'http://localhost:3000',
|
||||
|
||||
SIMRS_API: 'http://10.10.150.131:8084/api' // local Ahdan
|
||||
SIMRS_API: 'http://10.10.150.131:8084/api', // local Ahdan
|
||||
// SIMRS_API: 'http://10.10.123.140:8084/api'
|
||||
MONGODB_URI: 'mongodb://admin:*****@10.10.123.206:27017/?retryWrites=true&loadBalanced=false&serverSelectionTimeoutMS=5000&connectTimeoutMS=10000&authSource=admin&authMechanism=SCRAM-SHA-1',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
+8
-3
@@ -11,14 +11,18 @@
|
||||
"postinstall": "nuxt prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/vue": "^4.1.1",
|
||||
"@iconify/vue": "^4.3.0",
|
||||
"@mdi/font": "7.4.47",
|
||||
"@nuxt/vite-builder": "3.16.2",
|
||||
"@pinia/nuxt": "^0.11.0",
|
||||
"@vueform/nuxt": "^1.13.0",
|
||||
"apexcharts": "4.5.0",
|
||||
"axios": "^1.9.0",
|
||||
"cors": "^2.8.5",
|
||||
"nuxt-auth-utils": "^0.5.16",
|
||||
"module": "^1.2.5",
|
||||
"mongose": "0.0.2-security",
|
||||
"nuxt-auth-utils": "^0.5.20",
|
||||
"nuxt-mongoose": "^1.0.6",
|
||||
"openid-client": "^5.7.1",
|
||||
"pinia": "^3.0.2",
|
||||
"sass": "1.70.0",
|
||||
@@ -27,10 +31,11 @@
|
||||
"vue3-apexcharts": "1.5.2",
|
||||
"vue3-perfect-scrollbar": "1.6.1",
|
||||
"vuetify": "3.7.18",
|
||||
"zod": "^3.25.46"
|
||||
"zod": "^3.25.49"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sidebase/nuxt-auth": "^0.10.1",
|
||||
"@sidebase/nuxt-session": "^0.2.8",
|
||||
"nuxt": "3.16.2"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
+32
-1
@@ -1,14 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import UiParentCard from "@/components/shared/UiParentCard.vue";
|
||||
import { useSidebarStore } from "~/stores/api/sidebar";
|
||||
const { getSidebar } = useSidebarStore()
|
||||
const runtime = useRuntimeConfig();
|
||||
const { session, refresh, update, reset, overwrite } = await useSession()
|
||||
|
||||
|
||||
const sidebar = async () => {
|
||||
console.log('erwer')
|
||||
// await overwrite({ "test": "This replaces all current data of the session without overwriting the current session itself" })
|
||||
|
||||
console.log(session.value)
|
||||
// const a = await getSidebar()
|
||||
const res = await $fetch(`http://10.10.150.131:8080/api/login/6835632801e46cf9c5551876`, {
|
||||
mode: 'no-cors',
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
withCredentials: true,
|
||||
credentials: 'include',
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
}
|
||||
|
||||
const resett = async () => {
|
||||
await reset()
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<v-row>
|
||||
<v-col cols="12" md="12">
|
||||
<v-card elevation="10">
|
||||
<v-card-item>
|
||||
<h5 class="text-h5 mb-3">Sample Page</h5>
|
||||
<h5 class="text-h5 mb-3">Sample Page</h5>
|
||||
<p class="text-body-1">This is a sample page</p>
|
||||
<v-btn @click="sidebar" color="primary" size="large" block flat>get</v-btn>
|
||||
<v-btn @click="resett" color="primary" size="large" block flat>reset</v-btn>
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
Generated
+4058
-1300
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
import axios from "axios";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const read_body = await readBody(event)
|
||||
console.log(`ini ${read_body}`)
|
||||
try {
|
||||
const response = await axios.get(`http://10.10.150.131:8080/api/login/${read_body.key}`)
|
||||
// console.log(response.data.data)
|
||||
|
||||
return response.data.data
|
||||
} catch (error) {
|
||||
console.log(`Messages Err: ${error.response.data.message} || nullable`)
|
||||
throw createError({
|
||||
statusCode: error.response?.status || 500,
|
||||
statusMessage: error.message || 'Internal Server Error',
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
@@ -0,0 +1,28 @@
|
||||
import axios from 'axios'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
// export const useMySidebarStore = defineStore({
|
||||
// id: 'mySidebarStore',
|
||||
// state: () => ({ }),
|
||||
// actions: {}
|
||||
// })
|
||||
|
||||
export const useSidebarStore = defineStore('SidebarStore', () => {
|
||||
const getSidebar = async () => {
|
||||
console.log('aaaaa')
|
||||
const res = await $fetch(`http://10.10.150.131:8080/api/login/6835632801e46cf9c5551876`, {
|
||||
mode: 'no-cors',
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
}
|
||||
return {
|
||||
getSidebar
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user