feat: connexionButton

This commit is contained in:
2026-01-30 15:39:32 -05:00
parent 28f6e1ae7c
commit 87be06ecea
4 changed files with 15 additions and 5 deletions

View File

@@ -2,5 +2,6 @@ export function useAuth() {
const { loggedIn: isLoggedIn, session } = useUserSession();
const hasRole = (role: string) => session.value?.user?.roles?.includes(role) || false;
const isAdmin = computed(() => hasRole("administrator"));
return { isLoggedIn, hasRole, isAdmin };
}

View File

@@ -3,6 +3,7 @@ import type { FormSubmitEvent } from "@nuxt/ui";
const isRedirecting = ref(false);
export function useAuthConnexion() {
const { isLoggedIn } = useAuth();
const toast = useToast();
const { fetch: refreshUserSession } = useUserSession();
const routeRedirect = useRoute().query.redirect as string || undefined;
@@ -67,5 +68,12 @@ export function useAuthConnexion() {
}
}
return { isRedirecting, login, logout };
// Dynamic connexion link
const connexionButton = computed(() => ({
label: isLoggedIn.value ? "Déconnexion" : "Connexion",
icon: isLoggedIn.value ? "i-lucide-log-out" : "i-lucide-log-in",
to: "/connexion",
}));
return { isRedirecting, login, logout, connexionButton };
}