Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions apps/dashboard/src/@/constants/auth.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const LOGGED_IN_ONLY_PATHS = [
// anything that _starts_ with /dashboard is logged in only
"/dashboard",
// team pages are logged in only
"/team",
// anything that _starts_ with /cli is logged in only
"/cli",
// publish page
"/contracts/publish",
];

export function isLoginRequired(pathname: string) {
return LOGGED_IN_ONLY_PATHS.some((path) => pathname.startsWith(path));
// remove '/' in front and then split by '/'
const paths = pathname.slice(1).split("/");

// /dashboard, /team, /cli
if (paths[0] === "dashboard" || paths[0] === "team" || paths[0] === "cli") {
return true;
}

// /contracts/publish
if (paths[0] === "contracts" && paths[1] === "publish") {
return true;
}

return false;
}
Loading