Skip to content

Commit

Permalink
add hide if unauthed option
Browse files Browse the repository at this point in the history
  • Loading branch information
dhawton committed Oct 15, 2022
1 parent 993a885 commit f885000
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/AuthLink.vue
Expand Up @@ -2,7 +2,7 @@
<RouterLink v-if="display" v-bind="$attrs" :to="props.to">
<slot />
</RouterLink>
<div v-else>
<div v-else-if="!display && !hideUnauthed">
<slot />
</div>
</template>
Expand All @@ -16,11 +16,13 @@ import useUserStore from "@/stores/users";
const props = withDefaults(
defineProps<{
to: RouteLocationRaw;
hideUnauthed?: boolean;
auth?: boolean;
roles?: string[];
}>(),
{
auth: false,
hideUnauthed: false,
roles: () => [],
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/views/pages/HomePage.vue
Expand Up @@ -8,7 +8,7 @@
</p>
<p>
<!-- This is to demo/test a link that will only be a link if authenticated... -->
<AuthLink to="#" :auth="true" :roles="['wm']">
<AuthLink to="#" :auth="true" :roles="['wm']" :hide-unauthed="true">
<span class="text-green-500">Authenticated if linked</span>
</AuthLink>
</p>
Expand Down

0 comments on commit f885000

Please sign in to comment.