From 2eaf7732ff8004adfc254b1bdc045b9c43c1adb0 Mon Sep 17 00:00:00 2001 From: MananTank Date: Mon, 4 Nov 2024 21:17:31 +0000 Subject: [PATCH] Fix /dashboards path redirecting to /login (#5291) Fixes: DASH-395 --- apps/dashboard/src/@/constants/auth.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/dashboard/src/@/constants/auth.ts b/apps/dashboard/src/@/constants/auth.ts index fa16695bf8c..282de6f1dc0 100644 --- a/apps/dashboard/src/@/constants/auth.ts +++ b/apps/dashboard/src/@/constants/auth.ts @@ -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; }