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.

Block demo user from deleting account and changing password (v2.4.1)

Maurice3edf65957b18
diff --git a/server/package.json b/server/package.json
index d038eed94..092648535 100644
--- a/server/package.json
+++ b/server/package.json
@@ -1,6 +1,6 @@
{
"name": "nomad-server",
- "version": "2.4.0",
+ "version": "2.4.1",
"main": "src/index.js",
"scripts": {
"start": "node --experimental-sqlite src/index.js",
diff --git a/server/src/routes/auth.js b/server/src/routes/auth.js
index 1bf65d1c9..4fc1b6a84 100644
--- a/server/src/routes/auth.js
+++ b/server/src/routes/auth.js
@@ -189,6 +189,9 @@ router.get('/me', authenticate, (req, res) => {
// PUT /api/auth/me/password
router.put('/me/password', authenticate, (req, res) => {
+ if (process.env.DEMO_MODE === 'true' && req.user.email === '[email protected]') {
+ return res.status(403).json({ error: 'Password change is disabled in demo mode.' });
+ }
const { new_password } = req.body;
if (!new_password) return res.status(400).json({ error: 'New password is required' });
if (new_password.length < 8) return res.status(400).json({ error: 'Password must be at least 8 characters' });
@@ -200,6 +203,10 @@ router.put('/me/password', authenticate, (req, res) => {
// DELETE /api/auth/me — delete own account
router.delete('/me', authenticate, (req, res) => {
+ // Block demo user
+ if (process.env.DEMO_MODE === 'true' && req.user.email === '[email protected]') {
+ return res.status(403).json({ error: 'Account deletion is disabled in demo mode.' });
+ }
// Prevent deleting last admin
if (req.user.role === 'admin') {
const adminCount = db.prepare("SELECT COUNT(*) as count FROM users WHERE role = 'admin'").get().count;