setting, session and profile fix

This commit is contained in:
debu-2 2026-10-07 03:36:56 +05:30
parent e3d8215f2f
commit 068142ed61
7 changed files with 134 additions and 66 deletions

View file

@ -1,6 +1,9 @@
export const AUTH_TOKEN_KEY = "agmail_access_token";
export const AUTH_ACCOUNT_KEY = "agmail_account";
export const APP_HOME_PATH = "/app";
export const SESSION_GATED_PATHS = new Set(["/", "/login", "/signup", "/forgot-password"]);
let sessionRedirecting = false;
export function getAccessToken() {
@ -16,8 +19,25 @@ export function clearSession() {
sessionStorage.removeItem(AUTH_ACCOUNT_KEY);
}
export function currentPath() {
const path = window.location.pathname;
if (!path || path === "/") return "/";
return path.replace(/\/+$/, "") || "/";
}
export function enterApp(mode = "replace") {
if (currentPath() === APP_HOME_PATH && !window.location.search && !window.location.hash) {
return;
}
if (mode === "assign") {
window.location.assign(APP_HOME_PATH);
return;
}
window.history.replaceState(null, "", APP_HOME_PATH);
}
export function getBrandHomeHref() {
return isLoggedIn() ? "/app" : "/";
return isLoggedIn() ? APP_HOME_PATH : "/";
}
export function redirectSessionExpired() {
@ -26,3 +46,4 @@ export function redirectSessionExpired() {
clearSession();
window.location.replace("/?session=expired");
}