diff --git a/attached_assets/Pasted-HEAD-api-health-200-in-1ms-Error-updating-user-Error-ERR-MODULE-NOT-FOUND-Cannot-find-module-1754941254642_1754941254643.txt b/attached_assets/Pasted-HEAD-api-health-200-in-1ms-Error-updating-user-Error-ERR-MODULE-NOT-FOUND-Cannot-find-module-1754941254642_1754941254643.txt new file mode 100644 index 0000000..5d9d1d3 --- /dev/null +++ b/attached_assets/Pasted-HEAD-api-health-200-in-1ms-Error-updating-user-Error-ERR-MODULE-NOT-FOUND-Cannot-find-module-1754941254642_1754941254643.txt @@ -0,0 +1,140 @@ +HEAD /api/health 200 in 1ms + +Error updating user: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/dist/localAuth.production.js' imported from /app/dist/index.js + + at finalizeResolution (node:internal/modules/esm/resolve:283:11) + + at moduleResolve (node:internal/modules/esm/resolve:952:10) + + at defaultResolve (node:internal/modules/esm/resolve:1188:11) + + at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12) + + at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25) + + at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38) + + at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38) + + at ModuleLoader.import (node:internal/modules/esm/loader:539:34) + + at defaultImportModuleDynamicallyForModule (node:internal/modules/esm/utils:221:31) + + at importModuleDynamicallyCallback (node:internal/modules/esm/utils:260:12) { + + code: 'ERR_MODULE_NOT_FOUND', + + url: 'file:///app/dist/localAuth.production.js' + +} + +PUT /api/users/admin_local 500 in 14ms + +HEAD /api/health 200 in 1ms + +Error assigning user to group: error: column "created_at" of relation "user_groups" does not exist + + 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.assignUserToGroup (file:///app/dist/index.js:1225:32) + + at async file:///app/dist/index.js:3842:25 { + + length: 134, + + severity: 'ERROR', + + code: '42703', + + detail: undefined, + + hint: undefined, + + position: '51', + + internalPosition: undefined, + + internalQuery: undefined, + + where: undefined, + + schema: undefined, + + table: undefined, + + column: undefined, + + dataType: undefined, + + constraint: undefined, + + file: 'parse_target.c', + + line: '1075', + + routine: 'checkInsertTargets' + +} + +POST /api/users/admin_local/groups 500 in 55ms + +Error assigning user to group: error: column "created_at" of relation "user_groups" does not exist + + 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.assignUserToGroup (file:///app/dist/index.js:1225:32) + + at async file:///app/dist/index.js:3842:25 { + + length: 134, + + severity: 'ERROR', + + code: '42703', + + detail: undefined, + + hint: undefined, + + position: '51', + + internalPosition: undefined, + + internalQuery: undefined, + + where: undefined, + + schema: undefined, + + table: undefined, + + column: undefined, + + dataType: undefined, + + constraint: undefined, + + file: 'parse_target.c', + + line: '1075', + + routine: 'checkInsertTargets' + +} + +POST /api/users/admin_local/groups 500 in 27ms + +HEAD /api/health 200 in 2ms + + + + + \ No newline at end of file diff --git a/attached_assets/image_1754941198941.png b/attached_assets/image_1754941198941.png new file mode 100644 index 0000000..b70751a Binary files /dev/null and b/attached_assets/image_1754941198941.png differ diff --git a/attached_assets/image_1754941240030.png b/attached_assets/image_1754941240030.png new file mode 100644 index 0000000..526a840 Binary files /dev/null and b/attached_assets/image_1754941240030.png differ diff --git a/server/routes.ts b/server/routes.ts index e503579..b0025c2 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -6,6 +6,23 @@ import { requireModulePermission, requireAdmin } from "./permissions"; console.log('🔍 Using development storage and authentication'); +// Function to get the correct hashPassword function based on environment +async function getHashPassword() { + if (process.env.NODE_ENV === 'production') { + try { + const prodAuth = await import("./localAuth.production.js"); + return prodAuth.hashPassword; + } catch (error) { + console.error('❌ Failed to import production auth, falling back to dev auth:', error); + const devAuth = await import("./localAuth"); + return devAuth.hashPassword; + } + } else { + const devAuth = await import("./localAuth"); + return devAuth.hashPassword; + } +} + // Alias pour compatibilité const isAuthenticated = requireAuth; @@ -887,9 +904,7 @@ export async function registerRoutes(app: Express): Promise { // Hash password if provided (for local auth) if (userData.password) { - // Import from the correct auth module based on environment - const authModule = process.env.NODE_ENV === 'production' ? "./localAuth.production.js" : "./localAuth"; - const { hashPassword } = await import(authModule); + const hashPassword = await getHashPassword(); userData.password = await hashPassword(userData.password); } @@ -945,9 +960,7 @@ export async function registerRoutes(app: Express): Promise { // Hash password if provided if (userData.password) { - // Import from the correct auth module based on environment - const authModule = process.env.NODE_ENV === 'production' ? "./localAuth.production.js" : "./localAuth"; - const { hashPassword } = await import(authModule); + const hashPassword = await getHashPassword(); userData.password = await hashPassword(userData.password); // Mark password as changed (userData as any).passwordChanged = true;