Skip to content

Commit 2eaf773

Browse files
committed
Fix /dashboards path redirecting to /login (#5291)
Fixes: DASH-395
1 parent c0b8750 commit 2eaf773

File tree

1 file changed

+14
-12
lines changed
  • apps/dashboard/src/@/constants

1 file changed

+14
-12
lines changed
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
const LOGGED_IN_ONLY_PATHS = [
2-
// anything that _starts_ with /dashboard is logged in only
3-
"/dashboard",
4-
// team pages are logged in only
5-
"/team",
6-
// anything that _starts_ with /cli is logged in only
7-
"/cli",
8-
// publish page
9-
"/contracts/publish",
10-
];
11-
121
export function isLoginRequired(pathname: string) {
13-
return LOGGED_IN_ONLY_PATHS.some((path) => pathname.startsWith(path));
2+
// remove '/' in front and then split by '/'
3+
const paths = pathname.slice(1).split("/");
4+
5+
// /dashboard, /team, /cli
6+
if (paths[0] === "dashboard" || paths[0] === "team" || paths[0] === "cli") {
7+
return true;
8+
}
9+
10+
// /contracts/publish
11+
if (paths[0] === "contracts" && paths[1] === "publish") {
12+
return true;
13+
}
14+
15+
return false;
1416
}

0 commit comments

Comments
 (0)