mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
refactor(server): let user-cleanup inject BudgetService and delete budget.bridge
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user