Add Scene 7 claim report workflow

This commit is contained in:
2026-08-22 17:02:30 +02:00
parent a7f99a2a39
commit cea0d56cb9
23 changed files with 638 additions and 82 deletions
+6 -1
View File
@@ -1,7 +1,7 @@
import type { NextFunction, Request, Response } from 'express'
import jwt, { type JwtPayload } from 'jsonwebtoken'
export type OsintClaims = JwtPayload & { role?: string; isAdmin?: boolean }
export type OsintClaims = JwtPayload & { role?: string; isAdmin?: boolean; name?:string; preferred_username?:string }
declare global {
namespace Express {
@@ -39,6 +39,11 @@ export function resolveUserId(req: Request): string {
return typeof sub === 'string' && sub.length > 0 ? sub : DEVELOPMENT_TEST_USER_ID
}
export function resolvePlayerName(req: Request): string {
const candidate = req.authClaims?.name || req.authClaims?.preferred_username || req.authClaims?.sub
return typeof candidate === 'string' && candidate.trim() ? candidate.trim().slice(0,300) : 'Player'
}
export function requireAdmin(req: Request, res: Response, next: NextFunction) {
if (!hasAdminClaim(req)) return res.status(403).json({ error: 'Administrator claim required' })
next()