fix sanctions and admin role escalation

This commit is contained in:
Hide_D committed 2026-07-26 18:11:01 +00:00
1 parent 3fb75ccf03
commit ab6ed3553a
13 files changed
+591 -51

No files matched your search

+8
View File
@@ -1,5 +1,6 @@
import { randomUUID } from 'node:crypto';
import { initTRPC, TRPCError } from '@trpc/server';
import { isGameAccessBlocked } from '@sammo-ts/common/auth/sanctions';
import type { GameApiContext } from './context.js';
import { IdempotentTurnDaemonTransport } from './daemon/idempotentTransport.js';
@@ -14,6 +15,13 @@ const requireAuthMiddleware = t.middleware(({ ctx, next }) => {
message: 'Unauthorized',
});
}
const profileNames = ctx.profile ? [ctx.profile.name, ctx.profile.id] : [];
if (isGameAccessBlocked(ctx.auth.sanctions, profileNames)) {
throw new TRPCError({
code: 'FORBIDDEN',
message: 'Game access is restricted for this account.',
});
}
return next({
ctx: {
...ctx,