Something went wrong. Try again.
Something went wrong. Try again.
580 B · 17 lines
TypeScript
123456789101112131415161718import { requireSession, switchAccount } from '#server/utils/server-session'
export default defineEventHandler(async event => { await requireSession(event) const body = await readBody<{ did?: unknown }>(event) const did = typeof body?.did === 'string' ? body.did : null if (!did) { throw createError({ statusCode: 400, statusMessage: 'missing did' }) }
const switched = await switchAccount(event, did) if (!switched) { throw createError({ statusCode: 404, statusMessage: 'account not signed in on this device' }) }
return { ok: true, active: did }})