Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

refactor(demo): keep the demo password in one place

Maurice23196aa03895
diff --git a/server/src/demo/demo-seed.ts b/server/src/demo/demo-seed.ts
index c10291055..c08e1753d 100644
--- a/server/src/demo/demo-seed.ts
+++ b/server/src/demo/demo-seed.ts
@@ -1,6 +1,7 @@
import bcrypt from 'bcryptjs';
import Database from 'better-sqlite3';
import { readEnv } from '../app-config';
+import { DEMO_PASS } from '../nest/common/demo';
// Static like in demo-reset.job.ts: the module top is inert, everything that
// touches the database happens inside the functions.
import { saveBaseline, hasBaseline } from './demo-reset';
@@ -10,7 +11,6 @@ function seedDemoData(db: Database.Database): { adminId: number; demoId: number
const ADMIN_EMAIL = readEnv().demo.adminEmailRaw || '[email protected]';
const ADMIN_PASS = readEnv().demo.adminPass;
const DEMO_EMAIL = '[email protected]';
- const DEMO_PASS = 'demo12345';
// Create admin user if not exists
let admin = db.prepare('SELECT id FROM users WHERE email = ?').get(ADMIN_EMAIL) as { id: number } | undefined;
diff --git a/server/src/nest/auth/auth.service.ts b/server/src/nest/auth/auth.service.ts
index a18dab305..f7bfcddc2 100644
--- a/server/src/nest/auth/auth.service.ts
+++ b/server/src/nest/auth/auth.service.ts
@@ -25,7 +25,7 @@ import { splitManagedKeys } from '../common/managed';
import { emitUserDeleted } from '../../plugin-user-lifecycle';
import { verifyJwtAndLoadUser } from './jwt-verify';
import { User } from '../../types';
-import { DEMO_EMAIL_PRIMARY, isDemoEmail } from '../common/demo';
+import { DEMO_EMAIL_PRIMARY, DEMO_PASS, isDemoEmail } from '../common/demo';
import { avatarUrl } from '../common/avatarUrl';
import { TripMembershipService } from '../trip-membership/trip-membership.service';
import { WebauthnConfigService } from './webauthn-config.service';
@@ -303,7 +303,7 @@ export class AuthService {
managed: readEnv().managed.enabled,
demo_mode: isDemo,
demo_email: isDemo ? DEMO_EMAIL_PRIMARY : undefined,
- demo_password: isDemo ? 'demo12345' : undefined,
+ demo_password: isDemo ? DEMO_PASS : undefined,
timezone: readEnv().app.tz || Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC',
notification_channel: notifChannel,
notification_channels: activeChannels,
diff --git a/server/src/nest/common/demo.ts b/server/src/nest/common/demo.ts
index 8e30cd3b3..e6b34d450 100644
--- a/server/src/nest/common/demo.ts
+++ b/server/src/nest/common/demo.ts
@@ -10,6 +10,14 @@
export const DEMO_EMAIL_PRIMARY = '[email protected]';
+/**
+ * The demo account's password. Public on purpose — a demo instance shows it on
+ * the login screen so visitors can get in — but it was written out twice, in the
+ * seeder and in the config payload, which is one copy too many for something the
+ * seeder has to match exactly for the login to work.
+ */
+export const DEMO_PASS = 'demo12345';
+
/**
* All email addresses that should be treated as the demo account.
* Includes the historical `[email protected]` identifier so instances that