Add Scene 7 claim report workflow
This commit is contained in:
+6
-1
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user