fix: AuthGate stuck on Loading — verify returns flat user object

The auth /verify endpoint returns { user_id, name, email, is_admin, caps }
directly, not wrapped in a user key, so data.user was undefined and the
gate never rendered. Also: caps come back as bare slugs when ?app= is
passed, so the prefixed room-planner:cap checks always failed — replaced
with the standard can(user, cap) helper honouring is_admin.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-03 16:25:20 +00:00
parent 2993dfa216
commit 5a2dab637c
5 changed files with 14 additions and 7 deletions

View file

@ -24,7 +24,7 @@ export default function AuthGate({ children }: { children: React.ReactNode }) {
if (!r.ok) throw new Error(`Auth check failed: ${r.status}`)
return r.json()
})
.then(data => { if (data) setUser(data.user) })
.then(data => { if (data) setUser(data) })
.catch(err => setError(err.message))
}, [])