diff options
| author | Fuwn <[email protected]> | 2026-03-28 06:02:54 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-28 06:04:13 +0000 |
| commit | 8a99dd5c4b74a4ea2ce715aed5e517022621f05c (patch) | |
| tree | 56e24474d2240e77887450e0e52617e358ac3379 /src/lib/Data | |
| parent | fix(cache): respect AniList media list recache windows (diff) | |
| download | due.moe-8a99dd5c4b74a4ea2ce715aed5e517022621f05c.tar.xz due.moe-8a99dd5c4b74a4ea2ce715aed5e517022621f05c.zip | |
fix(auth): ignore malformed user cookies
Diffstat (limited to 'src/lib/Data')
| -rw-r--r-- | src/lib/Data/AniList/identity.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/Data/AniList/identity.ts b/src/lib/Data/AniList/identity.ts index eacc2ae4..973e1184 100644 --- a/src/lib/Data/AniList/identity.ts +++ b/src/lib/Data/AniList/identity.ts @@ -34,3 +34,17 @@ export const userIdentity = async ( avatar: userIdResponse["data"]["Viewer"]["avatar"]["large"], }; }; + +export const safeUserIdentity = async ( + anilistAuthorisation: AniListAuthorisation, +): Promise<UserIdentity | null> => { + try { + const identity = await userIdentity(anilistAuthorisation); + + if (!identity.id || !identity.name || !identity.avatar) return null; + + return identity; + } catch { + return null; + } +}; |