Skip to content

Commit

Permalink
feat: Add users link in app footer
Browse files Browse the repository at this point in the history
  • Loading branch information
lewebsimple committed Dec 11, 2023
1 parent 8d75a85 commit 585a3d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/components/app/TheAppFooter.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<script setup lang="ts">
const { isAdministrator } = useAuth();
</script>

<template>
<footer class="py-2 bg-muted">
<div class="container flex justify-between items-center gap-4">
<AppVersion />
<div class="container flex items-center gap-4">
<AppVersion class="mr-auto" />
<UButton color="gray" variant="link" to="/auth/users" label="Utilisateurs" />
<AuthButton />
</div>
</footer>
Expand Down
3 changes: 2 additions & 1 deletion auth/composables/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function useAuth() {

// Authentication helpers
const isAuthenticated = computed(() => !!session.value?.user);
const isAdministrator = computed(() => hasAuthRole(AuthRole.Administrator));
const hasAuthRole = (role: AuthRole) => session.value?.user && [AuthRole.Administrator, role].includes(session.value.user.role);

// Login handler
Expand Down Expand Up @@ -53,5 +54,5 @@ export function useAuth() {
session.value = data.value?.session || null;
}

return { session, isAuthenticated, hasAuthRole, login, logout };
return { session, isAuthenticated, isAdministrator, hasAuthRole, login, logout };
}

0 comments on commit 585a3d4

Please sign in to comment.