Skip to content

Commit

Permalink
Guard permission checks for empty jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Sep 6, 2023
1 parent 75d00fa commit 8827c35
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/auth/auth.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export function useAuth() {

const isAuthenticated = computed(() => !!jwt.value);
const payload = computed(() => decodeJwt(jwt.value)?.payload);
const canUserAdmin = computed(() =>
canAdmin(payload.value, "other", "mink-app")
const canUserAdmin = computed(
() => payload.value && canAdmin(payload.value, "other", "mink-app")
);
const canUserWrite = computed(() =>
canWrite(payload.value, "other", "mink-app")
const canUserWrite = computed(
() => payload.value && canWrite(payload.value, "other", "mink-app")
);

/** If not authenticated, redirect to the login page. */
Expand Down

0 comments on commit 8827c35

Please sign in to comment.