feat: use keycloak

This commit is contained in:
Ron
2025-05-22 23:28:32 +03:00
parent 867ba7746d
commit 89d8fbc843
9 changed files with 47 additions and 111 deletions

View File

@@ -1,35 +1,17 @@
<template>
<v-app full-height>
<v-navigation-drawer
v-model="drawer"
:location="mdAndDown ? 'bottom' : undefined"
>
<v-navigation-drawer v-model="drawer" :location="mdAndDown ? 'bottom' : undefined">
<v-img v-if="!mdAndDown" src="/logo.jpg" height="75" class="my-6" />
<v-list color="primary" lines="two">
<v-list-item
v-for="(item, index) in menu"
:key="index"
:to="item.to"
:title="item.title"
:prepend-icon="item.icon"
/>
<v-list-item v-for="(item, index) in menu" :key="index" :to="item.to" :title="item.title"
:prepend-icon="item.icon" />
</v-list>
<template #append>
<v-list lines="two">
<v-list-item
v-if="user"
:title="`${user.first_name} ${user.last_name}`"
:subtitle="user.email"
prepend-icon="mdi-account"
/>
<v-list-item
@click="logOut"
title="Log out"
prepend-icon="mdi-logout"
base-color="error"
/>
<v-list-item title="Logged in" prepend-icon="mdi-account" />
<v-list-item @click="logOut" title="Log out" prepend-icon="mdi-logout" base-color="error" />
</v-list>
</template>
</v-navigation-drawer>
@@ -42,13 +24,7 @@
<v-img src="/logo.jpg" height="50" />
<template #append>
<v-btn
@click="logOut"
class="mr-3"
variant="text"
color="error"
icon="mdi-logout"
/>
<v-btn @click="logOut" class="mr-3" variant="text" color="error" icon="mdi-logout" />
</template>
</v-app-bar>
@@ -60,18 +36,14 @@
<script setup>
definePageMeta({
middleware: ["authentication"],
layout: false,
});
const { mdAndDown } = useDisplay();
const { logout } = useDirectusAuth();
const user = useDirectusUser();
const tags = usePortalTags();
const drawer = ref(false);
const interestMenu = [
const menu = ref([
{
to: "/dashboard/interest-eoi-queue",
icon: "mdi-tray-full",
@@ -102,11 +74,6 @@ const interestMenu = [
icon: "mdi-account-check",
title: "Interest Status",
},
];
const defaultMenu = [
{
to: "/dashboard/site",
icon: "mdi-view-dashboard",
@@ -117,14 +84,9 @@ const defaultMenu = [
icon: "mdi-finance",
title: "Data Analytics",
},
];
const menu = computed(() =>
toValue(tags).interest ? interestMenu : defaultMenu
);
]);
const logOut = async () => {
await logout();
return navigateTo("/login");
};

View File

@@ -1,9 +1,3 @@
<script lang="ts" setup>
const tags = usePortalTags();
onBeforeMount(() =>
navigateTo(
toValue(tags).interest ? "/dashboard/interest-analytics" : "/dashboard/site"
)
);
onBeforeMount(() => navigateTo("/dashboard/interest-analytics"));
</script>