chore(frontend): delete lib/editToken.ts (replaced by OAuth)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
shay
2026-04-19 19:18:32 -04:00
co-authored by Claude Opus 4.7
parent ccdd8231ce
commit be8823c4cf
-36
View File
@@ -1,36 +0,0 @@
// Per-username edit token issued by the backend at enrollment. Presented
// as `Authorization: Bearer` on mutating endpoints (PATCH settings,
// POST refresh). Stored in localStorage so a reload keeps the user in
// control of their own profile.
//
// Without this token the backend rejects mutations with HTTP 401. Token is
// only surfaced on the FIRST enroll for a given username — re-hitting the
// enroll path for an existing user returns no token, so we never blow away
// a previously-saved token.
const STORAGE_PREFIX = 'grs:edit_token:'
const keyFor = (username: string) => STORAGE_PREFIX + username.toLowerCase()
export function getEditToken(username: string): string | null {
if (!username) return null
try {
return window.localStorage.getItem(keyFor(username))
} catch {
return null
}
}
export function saveEditToken(username: string, token: string | null | undefined): void {
if (!username || !token) return
try {
window.localStorage.setItem(keyFor(username), token)
} catch {
// localStorage can throw in private mode — fall through silently.
}
}
export function authHeaders(username: string): Record<string, string> {
const t = getEditToken(username)
return t ? { Authorization: `Bearer ${t}` } : {}
}