Compare commits
2 Commits
9b7a8df99a
...
bb08a62e5d
| Author | SHA1 | Date | |
|---|---|---|---|
| bb08a62e5d | |||
| 129da829e7 |
@@ -9,13 +9,18 @@
|
||||
<v-app-bar-title class="text-h6 ms-3 text-white">
|
||||
<v-icon icon="mdi-apps" @click="drawer = !drawer"></v-icon>
|
||||
|
||||
<span class="ms-1 text-white">Listas de Front</span>
|
||||
<span class="ms-1 text-white">{{ data.email }}</span>
|
||||
</v-app-bar-title>
|
||||
|
||||
<!-- Spacer to push the following elements to the right -->
|
||||
<v-spacer />
|
||||
|
||||
<!-- Menu icons on the right side of the toolbar -->
|
||||
<template v-slot:append>
|
||||
<small class="text-white"> Logout </small>
|
||||
<v-btn icon="mdi-account" class="text-white" @click="logout">
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-app-bar>
|
||||
|
||||
<v-navigation-drawer v-model="drawer" temporary>
|
||||
@@ -56,10 +61,16 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
const { status } = useAuth();
|
||||
import { ref, onMounted } from "vue";
|
||||
const { status, data, signOut } = useAuth();
|
||||
const systemStore = useSystemStore();
|
||||
// Drawer state to open/close the navigation drawer
|
||||
const drawer = ref(false);
|
||||
|
||||
const logout = async () => {
|
||||
await systemStore.deleteCookies();
|
||||
await signOut({ callbackUrl: "/login" });
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { fa } from "vuetify/locale";
|
||||
|
||||
// file: ~/middleware/authentication.global.ts
|
||||
export default defineNuxtRouteMiddleware(async (to, next) => {
|
||||
export default defineNuxtRouteMiddleware(async (to, from, next) => {
|
||||
const { status } = useAuth();
|
||||
const auth = status.value === "authenticated" ? true : false;
|
||||
const isProtected = (await to.meta.auth) === true ? true : false;
|
||||
if (!auth && isProtected) {
|
||||
// User is not authenticated and page is protected
|
||||
if (from.meta.auth) {
|
||||
//viene de una pagina protegida
|
||||
return navigateTo("/login");
|
||||
} //viene de una pagina no protegida
|
||||
return abortNavigation();
|
||||
} else if (auth && !isProtected) {
|
||||
// User is authenticated and page is not protected
|
||||
|
||||
Reference in New Issue
Block a user