ReviewOS

also looking at this

loghqorg/loghq

Deploy: uniform auth session model (main → production)

#7
Merged glennmichael123 wants to merge main into production
282 files +3028 -64856
app/Actions/MeAction.tsmodified+5-4
Changes to app/Actions/MeAction.ts
@@ -1,9 +1,9 @@
11import type { RequestInstance } from '@stacksjs/types'
22import { Action } from '@stacksjs/actions'
3import { Auth } from '@stacksjs/auth'
43import { db } from '@stacksjs/database'
54import { Payment } from '@stacksjs/payments'
65import { response } from '@stacksjs/router'
6import { userFromRequest } from '../Support/request-auth'
77
88/**
99 * Return the authenticated user plus their Pro status. The dashboard calls this
@@ -16,9 +16,10 @@ export default new Action({
1616 description: 'Return the current user and their Pro status',
1717 method: 'GET',
1818 async handle(request: RequestInstance) {
19 const authHeader = ((request as any).headers?.get?.('authorization') ?? '')
20 const bearer = (request as any).bearerToken?.() ?? authHeader.replace(/^Bearer\s+/i, '')
21 const user = bearer ? await Auth.getUserFromToken(bearer) : await request.user()
19 // Resolve from either carrier: an external bearer header, or the HttpOnly
20 // `auth-token` cookie the dashboard sends on same-origin fetches. /api/me
21 // has no `.middleware('auth')`, so the resolution happens here.
22 const user = await userFromRequest(request)
2223 if (!user)
2324 return response.unauthorized('Authentication required')
2425