use p2p_token everywhere; drop shared zino_token to avoid cross-app corruption
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
98afb6ad07
commit
cc997838bb
@ -1,6 +1,6 @@
|
|||||||
import { APP_ID } from "../config";
|
import { APP_ID } from "../config";
|
||||||
|
|
||||||
const TOKEN_KEY = "zino_token";
|
const TOKEN_KEY = "p2p_token";
|
||||||
|
|
||||||
function baseUrl(): string {
|
function baseUrl(): string {
|
||||||
return (import.meta.env.VITE_ZINO_API_URL || "https://studio.getzino.in").replace(/\/+$/, "");
|
return (import.meta.env.VITE_ZINO_API_URL || "https://studio.getzino.in").replace(/\/+$/, "");
|
||||||
@ -21,7 +21,7 @@ async function request<T>(method: string, path: string, body?: unknown): Promise
|
|||||||
});
|
});
|
||||||
if (res.status === 401) {
|
if (res.status === 401) {
|
||||||
localStorage.removeItem(TOKEN_KEY);
|
localStorage.removeItem(TOKEN_KEY);
|
||||||
localStorage.removeItem("zino_user");
|
localStorage.removeItem("p2p_user");
|
||||||
window.location.href = `${import.meta.env.BASE_URL}login`;
|
window.location.href = `${import.meta.env.BASE_URL}login`;
|
||||||
throw new Error("Unauthorized");
|
throw new Error("Unauthorized");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,8 +62,6 @@ export function useAuth() {
|
|||||||
|
|
||||||
localStorage.setItem(TOKEN_KEY, token);
|
localStorage.setItem(TOKEN_KEY, token);
|
||||||
localStorage.setItem(USER_KEY, JSON.stringify(user));
|
localStorage.setItem(USER_KEY, JSON.stringify(user));
|
||||||
// Also set on zino SDK so workflow/view calls get the token
|
|
||||||
localStorage.setItem("zino_token", token);
|
|
||||||
|
|
||||||
setState({ user, token, loading: false, error: null });
|
setState({ user, token, loading: false, error: null });
|
||||||
return { token, user };
|
return { token, user };
|
||||||
@ -79,7 +77,6 @@ export function useAuth() {
|
|||||||
const logout = useCallback(() => {
|
const logout = useCallback(() => {
|
||||||
localStorage.removeItem(TOKEN_KEY);
|
localStorage.removeItem(TOKEN_KEY);
|
||||||
localStorage.removeItem(USER_KEY);
|
localStorage.removeItem(USER_KEY);
|
||||||
localStorage.removeItem("zino_token");
|
|
||||||
setState({ user: null, token: null, loading: false, error: null });
|
setState({ user: null, token: null, loading: false, error: null });
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { ApiError, ZinoClientConfig } from "./types";
|
import type { ApiError, ZinoClientConfig } from "./types";
|
||||||
|
|
||||||
const TOKEN_KEY = "zino_token";
|
const TOKEN_KEY = "p2p_token";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core HTTP client for the Zino API.
|
* Core HTTP client for the Zino API.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user