Allow admin password to be changed and retained without resets

Modify production logic to prevent forced admin password resets on updates, allowing users to set and keep their own passwords unless explicitly overridden by an environment variable.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/kdCs97W
This commit is contained in:
michaelschal committed 2025-08-12 08:18:45 +00:00
1 parent 8e6f59e88a
commit 461290a4f8
2 files changed
+215 -17

No files matched your search

@@ -0,0 +1,199 @@
✅ Processed 0 groups for user admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
Orders API called with: {
startDate: undefined,
endDate: undefined,
storeId: undefined,
userRole: 'admin'
}
Admin filtering with groupIds: undefined
Fetching all orders
GET /api/publicities 304 in 143ms
GET /api/user 304 in 37ms
Deliveries returned: 80 items
Customer orders returned from storage: 32 items
GET /api/deliveries 200 in 182ms
Orders returned: 46 items
GET /api/customer-orders 200 in 177ms
GET /api/tasks 200 in 162ms
GET /api/orders 200 in 191ms
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
GET /api/dlc-products/stats 200 in 180ms
🔍 Querying user_groups for user: admin_local
GET /api/user 304 in 7ms
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getPublicities called with: { year: 2025, groupIds: undefined }
📢 Raw publicities found: 29
🏪 Participations found: 26
✅ Final publicities with participations: 29
📄 Sample publicity: {

,
pubNumber: '2526',
participations: [ { groupId: 2, groupName: 'Houdemont' } ]
}
GET /api/publicities 200 in 47ms
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
GET /api/groups 200 in 8ms
HEAD /api/health 200 in 1ms
HEAD /api/health 200 in 0ms
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
GET /api/user 304 in 33ms
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 getUserWithGroups called for user: admin_local
🔍 Querying user_groups for user: admin_local
🔍 Found 0 group assignments for user admin_local
🔍 Raw query result: []
✅ Processed 0 groups for user admin_local
🔍 ===== DÉBUT SCAN SCHÉMA BASE DE DONNÉES =====
⏰ Timestamp: 2025-08-12T08:18:10.753Z
❌ ERREUR lors du scan du schéma: TypeError: Cannot read properties of undefined (reading 'query')
at file:///app/dist/index.js:4455:45
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
GET /api/debug/log-schema 500 in 16ms
HEAD /api/health 200 in 0ms
+16 -17
View File
@@ -110,23 +110,22 @@ async function createDefaultAdminUser() {
passwordFormat: existingAdmin.password ? 'present' : 'missing'
});
// Test if current password works with 'admin'
if (existingAdmin.password) {
const testLogin = await comparePasswords('admin', existingAdmin.password);
if (!testLogin) {
console.log('🔄 Admin password incompatible with current system, forcing reset...');
try {
const newHashedPassword = await hashPassword('admin');
await storage.updateUser(existingAdmin.id, {
password: newHashedPassword,
passwordChanged: false
});
console.log('✅ Admin password force-reset to: admin/admin');
} catch (error) {
console.error('❌ Failed to reset admin password:', (error as Error).message);
}
} else {
console.log('✅ Admin password works with current system');
// Ne plus forcer la réinitialisation du mot de passe admin
// L'admin peut maintenant changer son mot de passe et il sera conservé
console.log('✅ Admin user exists, preserving current password');
// Seulement réinitialiser si explicitement demandé via FORCE_ADMIN_RESET
if (process.env.FORCE_ADMIN_RESET === 'true') {
console.log('🔄 FORCE_ADMIN_RESET env var set, resetting admin password...');
try {
const newHashedPassword = await hashPassword('admin');
await storage.updateUser(existingAdmin.id, {
password: newHashedPassword,
passwordChanged: false
});
console.log('✅ Admin password manually reset to: admin/admin');
} catch (error) {
console.error('❌ Failed to reset admin password:', (error as Error).message);
}
}
}