diff options
| author | Adam Soltys <[email protected]> | 2026-01-21 15:00:02 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-01-21 15:00:02 -0800 |
| commit | 5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13 (patch) | |
| tree | 33ad949937238d4b8d286829bf6418aed235fcf5 /src/lib | |
| parent | 76bbaa296e2fa5a0bf51e15dd8b51011b0ee4a1e (diff) | |
| download | coinos-ui-5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13.tar.gz coinos-ui-5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13.zip | |
redirect on invalid token
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/utils.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts index a3d9cd49..f220ed45 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -199,6 +199,20 @@ export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get("token")}`, }); +export const isInvalidTokenError = (e: unknown) => { + const message = (e as Error)?.message || ""; + if (!message) return false; + const normalized = message.toLowerCase(); + return ( + normalized.includes("jwt") || + normalized.includes("invalid token") || + normalized.includes("token expired") || + normalized.includes("expired token") || + normalized.includes("unauthorized") || + normalized.includes("not authorized") + ); +}; + export const btc = (fiat: number, rate: number): number => Math.round((fiat * sats) / rate); |
