refactor(server): let user-cleanup inject BudgetService and delete budget.bridge

This commit is contained in:
jubnl
2026-08-11 16:42:49 +02:00
parent 2b2c6462ec
commit 8b7b91d814
24 changed files with 117 additions and 109 deletions
+12
View File
@@ -1,4 +1,5 @@
import { RuntimeEnvService } from '../app-config/runtime-env.service';
import { DatabaseService } from '../database/database.service';
import { isDemoEmail } from './demo';
/** The exact 403 body the six upload endpoints have always returned. */
@@ -22,3 +23,14 @@ export const DEMO_WRITE_ERROR = {
export function isDemoWriteBlocked(env: RuntimeEnvService, email: string | null | undefined): boolean {
return env.isDemoMode() && isDemoEmail(email);
}
/**
* The user-id flavour of the demo guard — the AuthService.isDemoUser body,
* relocated so surfaces that hold only a user id (the *.mcp.ts demo guards)
* don't need the whole auth graph for one check.
*/
export function isDemoUserId(env: RuntimeEnvService, db: DatabaseService, userId: number): boolean {
if (!env.isDemoMode()) return false;
const user = db.get<{ email: string }>('SELECT email FROM users WHERE id = ?', userId);
return isDemoEmail(user?.email);
}