feature: prepare for demo mode

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-06-17 23:10:23 +02:00
parent 02be728499
commit 9b16bbaccd
3 changed files with 38 additions and 1 deletions

View File

@@ -88,7 +88,14 @@ const enforceUserIsAuthed = t.middleware(async ({ ctx, next }) => {
});
// Only used on protected routes
const enforceAccess = t.middleware(async ({ ctx, next, rawInput }) => {
const enforceAccess = t.middleware(async ({ ctx, next, rawInput, type }) => {
if (type === 'mutation' && process.env.DEMO_USER_ID) {
throw new TRPCError({
code: 'UNAUTHORIZED',
message: 'You are not allowed to do this in demo mode',
});
}
if (has('projectId', rawInput)) {
const access = await getProjectAccessCached({
userId: ctx.session.userId!,