diff --git a/attached_assets/Pasted--Database-initialization-NODE-ENV-production-isProduction-true-hasDb-1754936753635_1754936753635.txt b/attached_assets/Pasted--Database-initialization-NODE-ENV-production-isProduction-true-hasDb-1754936753635_1754936753635.txt new file mode 100644 index 0000000..91109d6 --- /dev/null +++ b/attached_assets/Pasted--Database-initialization-NODE-ENV-production-isProduction-true-hasDb-1754936753635_1754936753635.txt @@ -0,0 +1,182 @@ + +🔗 Database initialization: { + + NODE_ENV: 'production', + + isProduction: true, + + hasDbUrl: true, + + dbHost: 'logiflow-db' + +} + +🐳 PRODUCTION: Using standard PostgreSQL + +✅ PostgreSQL connection test successful + +🐳 PRODUCTION: Using PostgreSQL storage + +🐳 PRODUCTION: Local auth configured with PostgreSQL sessions + +🐳 PRODUCTION: Starting LogiFlow application + +🐳 Environment: { NODE_ENV: 'production', DATABASE_URL: 'Present', PORT: '3000' } + +🔍 Using development storage and authentication + +🔧 Using memory session store for development + +Warning: connect.session() MemoryStore is not + +designed for a production environment, as it will leak + +memory, and will not scale past a single process. + +🐳 Serving static files from: /app/dist/public + +🐳 PRODUCTION: LogiFlow serving on port 3000 + +✅ Production admin user found: { id: 'admin_local', username: 'admin', passwordFormat: 'present' } + +🔐 Production password comparison { suppliedLength: 5, storedFormat: '63d2ce518b...' } + +✅ Password matched with hash.salt format + +✅ Admin password works with current system + +HEAD /api/health 200 in 5ms + +Error updating user: error: duplicate key value violates unique constraint "users_email_key" + + at /app/node_modules/pg-pool/index.js:45:11 + + at process.processTicksAndRejections (node:internal/process/task_queues:95:5) + + at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22 + + at async DatabaseStorage.updateUser (file:///app/dist/index.js:1085:24) + + at async file:///app/dist/index.js:4051:27 { + + length: 210, + + severity: 'ERROR', + + code: '23505', + + detail: 'Key (email)=(admin@logiflow.com) already exists.', + + hint: undefined, + + position: undefined, + + internalPosition: undefined, + + internalQuery: undefined, + + where: undefined, + + schema: 'public', + + table: 'users', + + column: undefined, + + dataType: undefined, + + constraint: 'users_email_key', + + file: 'nbtinsert.c', + + line: '664', + + routine: '_bt_check_unique' + +} + +PUT /api/users/_1754936203292 500 in 96ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 0ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 16ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 4ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 1ms + +HEAD /api/health 200 in 3ms + +Error updating user: error: duplicate key value violates unique constraint "users_email_key" + + at /app/node_modules/pg-pool/index.js:45:11 + + at process.processTicksAndRejections (node:internal/process/task_queues:95:5) + + at async file:///app/node_modules/drizzle-orm/node-postgres/session.js:83:22 + + at async DatabaseStorage.updateUser (file:///app/dist/index.js:1085:24) + + at async file:///app/dist/index.js:4051:27 { + + length: 210, + + severity: 'ERROR', + + code: '23505', + + detail: 'Key (email)=(admin@logiflow.com) already exists.', + + hint: undefined, + + position: undefined, + + internalPosition: undefined, + + internalQuery: undefined, + + where: undefined, + + schema: 'public', + + table: 'users', + + column: undefined, + + dataType: undefined, + + constraint: 'users_email_key', + + file: 'nbtinsert.c', + + line: '664', + + routine: '_bt_check_unique' + +} + +PUT /api/users/_1754936203292 500 in 44ms + +HEAD /api/health 200 in 1ms \ No newline at end of file diff --git a/attached_assets/image_1754936742486.png b/attached_assets/image_1754936742486.png new file mode 100644 index 0000000..bf3e341 Binary files /dev/null and b/attached_assets/image_1754936742486.png differ diff --git a/server/routes.ts b/server/routes.ts index 495b130..7c2ebe9 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -954,11 +954,27 @@ export async function registerRoutes(app: Express): Promise { const updatedUser = await storage.updateUser(req.params.id, userData); res.json(updatedUser); - } catch (error) { + } catch (error: any) { console.error("Error updating user:", error); + if (error instanceof z.ZodError) { return res.status(400).json({ message: "Invalid user data", errors: error.errors }); } + + // Handle specific database constraint errors + if (error.code === '23505') { + if (error.constraint === 'users_username_key') { + return res.status(409).json({ + message: "Un utilisateur avec ce nom d'utilisateur existe déjà. Veuillez choisir un autre nom d'utilisateur." + }); + } + if (error.constraint === 'users_email_key') { + return res.status(409).json({ + message: "Un utilisateur avec cette adresse email existe déjà. Veuillez utiliser une autre adresse email ou laisser le champ vide." + }); + } + } + res.status(500).json({ message: "Failed to update user" }); } });