Skip to content

Commit

Permalink
Release: remove mink-app WRITE check, fix #107
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Sep 19, 2023
1 parent c4daa05 commit 58db17c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/auth/auth.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ export function useAuth() {
const canUserWrite = computed(
() => payload.value && canWrite(payload.value, "other", "mink-app")
);
/** Indicates whether a jwt request is currently loading. */
const isAuthenticating = computed(() => pending.value.includes("jwt"));

/** If not authenticated, redirect to the login page. */
async function requireAuthentication(callback) {
// First, ensure the jwt has been fetched.
if (!jwt.value) {
await refreshJwt();
}
// If still no jwt, it means the user hasn't authenticated. Show our login page.
if (!jwt.value) {
// By passing current page as destination param, the user will then be redirected back to where they first attempted to go.
router.push(`/login?destination=${route.fullPath}`);
return;
}
if (!canUserWrite.value) {
router.push("/access-denied");
return;
}
// When calling `requireAuthentication`, you can optionally specify what should happen upon success.
callback?.();
}

Expand Down

0 comments on commit 58db17c

Please sign in to comment.