Files
AWCharacterCreator/frontend/src/legacy.js
T
Claude 5f3b2b2874 Add accounts, presets, live sheet panel and equipment tiles
- Login with registration code, sessions, rate limiting, per-user characters
- Share characters with other users (read-only), admin CLI
- Rules presets with a Presets tab, applied/pending changes with diff in a side sheet
- Equipment as tiles with amounts, starting kit removed
- Rename nav tab to "Character", add "New character" button
- Stop tracking _to_delete/

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJhXuLD2Z6hv3Wqeq9UL9K
2026-10-20 20:37:09 +00:00

17 lines
916 B
JavaScript

// Characters and presets made before accounts existed were protected by secret keys in this browser.
// After login they are handed over to the account once; the old keys are then removed.
export async function claimLegacy() {
const post = (kind, id, token) =>
fetch(`/api/claim/${kind}/${id}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) }).catch(() => null)
try {
const chars = JSON.parse(localStorage.getItem('aw_chars')) || []
for (const c of chars) if (c?.id && c?.token) await post('characters', c.id, c.token)
localStorage.removeItem('aw_chars')
} catch { /* nothing to claim */ }
try {
const presets = JSON.parse(localStorage.getItem('aw_presets')) || {}
for (const [id, token] of Object.entries(presets)) await post('presets', id, token)
localStorage.removeItem('aw_presets')
} catch { /* nothing to claim */ }
}