mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 22:51:30 -07:00
clean up auth, some storage improvements
This commit is contained in:
@@ -15,15 +15,7 @@ import type { App } from './context'
|
||||
* claim isn't an integer.
|
||||
*/
|
||||
async function authedId(c: Context<App>): Promise<number | null> {
|
||||
const authHeader = c.req.header('Authorization') ?? ''
|
||||
if (!authHeader.toLowerCase().startsWith('bearer ')) return null
|
||||
|
||||
const token = authHeader.slice('Bearer '.length)
|
||||
const accountId = await validateAndGetAccountId(token, await c.env.JWT_SECRET.get())
|
||||
if (!accountId) return null
|
||||
|
||||
const id = Number.parseInt(accountId, 10)
|
||||
return Number.isNaN(id) ? null : id
|
||||
return validateAndGetAccountId(c.req.raw, await c.env.JWT_SECRET.get())
|
||||
}
|
||||
|
||||
/** Results.Unauthorized() equivalent — 401 with empty body. */
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('playersettings endpoints', () => {
|
||||
expect(settings.length).toBeGreaterThan(0)
|
||||
expect(settings.every((s) => s.PlayerId === 100)).toBe(true)
|
||||
expect(settings.find((s) => s.Key === 'Recroom.OOBE')?.Value).toBe('77')
|
||||
expect(settings.find((s) => s.Key === 'PlayerSessionCount')?.Value).toBe('13')
|
||||
expect(settings.find((s) => s.Key === 'TUTORIAL_COMPLETE_MASK')?.Value).toBe('11')
|
||||
|
||||
// Defaults were persisted to KV.
|
||||
const stored = await env.RECFLARE_PLAYER_SETTINGS.get<Record<string, string>>(
|
||||
|
||||
Reference in New Issue
Block a user