fix(demo): journey and collab uploads are refused for the demo account too

Six upload routes refused the shared demo account in demo mode; journey photos, videos, gallery media and covers, collab note files and chat images did not, so any visitor could put images in front of every other one for the hour. They answer the same 403 now, checked in the handler after the upload is read, and a text-only chat message still goes through. The Demo Mode wiki page lists them, and says document sync is not covered.
This commit is contained in:
Maurice
2026-10-25 00:46:23 +00:00
parent 42ed858853
commit 2372dde716
11 changed files with 395 additions and 108 deletions
@@ -1,6 +1,8 @@
import type { User } from '../../types';
import { RuntimeEnvService } from '../app-config/runtime-env.service';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { DEMO_WRITE_ERROR, isDemoWriteBlocked } from '../common/demo-write';
import { ResponseContract } from '../common/response-contract';
import { SpoolCleanupInterceptor } from '../common/spool-cleanup.interceptor';
import { BLOCKED_EXTENSIONS, MAX_FILE_SIZE } from '../files/files.constants';
@@ -130,6 +132,8 @@ export class CollabController {
constructor(
private readonly collab: CollabService,
private readonly storage: StorageService,
// Whether DEMO_MODE is on, read on every upload: the demo account's are refused.
private readonly env: RuntimeEnvService,
) {}
private async requireTrip(tripId: string, user: User) {
@@ -242,6 +246,12 @@ export class CollabController {
};
try {
const trip = await this.requireTrip(tripId, user);
// After the 404, as on the trip-file upload, so the demo account cannot
// learn which trips exist; refused like every other upload of it
// (common/demo-write.ts).
if (isDemoWriteBlocked(this.env, user.email)) {
throw new HttpException(DEMO_WRITE_ERROR, 403);
}
if (!(await this.collab.canUploadFiles(trip, user))) {
throw new HttpException({ error: 'No permission to upload files' }, 403);
}
@@ -491,6 +501,11 @@ export class CollabController {
cleanupSpool();
throw err;
}
// Only the images are refused to the demo account; its text still posts.
if (uploaded.length && isDemoWriteBlocked(this.env, user.email)) {
cleanupSpool();
throw new HttpException(DEMO_WRITE_ERROR, 403);
}
if (uploaded.length && !(await this.collab.canUploadFiles(trip, user))) {
cleanupSpool();
throw new HttpException({ error: 'No permission to upload files' }, 403);