authentication improvements

This commit is contained in:
Devin Zuczek
2026-07-06 21:08:24 -04:00
parent fbc1aedfcd
commit baf43bfe31
57 changed files with 536 additions and 146 deletions
+5 -2
View File
@@ -19,9 +19,9 @@ import {
getRoomsByCreator,
getRoomsByIds,
getSimilarRooms,
getVisitedRooms,
removeCheer,
removeFavorite,
getVisitedRooms,
saveSubRoomData,
searchRooms,
setRoomDescription,
@@ -132,7 +132,10 @@ async function handlePhotonAccessToken(c: Context<App>) {
async function authedAccountId(c: Context<App>): Promise<number | null> {
const authHeader = c.req.header('Authorization') ?? ''
if (!authHeader.toLowerCase().startsWith('bearer ')) return null
const sub = await validateAndGetAccountId(authHeader.slice('Bearer '.length))
const sub = await validateAndGetAccountId(
authHeader.slice('Bearer '.length),
await c.env.JWT_SECRET.get()
)
const id = sub ? Number.parseInt(sub, 10) : Number.NaN
return Number.isNaN(id) ? null : id
}