mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 18:59:18 +02:00
Improve user authentication and group assignment logic
Refactor user and group management to dynamically import authentication modules based on environment and address a missing 'created_at' column error in user group assignments. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a8a78c07-e900-425c-a577-5b4c5894379d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/a8a78c07-e900-425c-a577-5b4c5894379d/oleRdyv
This commit is contained in:
1 parent
f42a999b61
commit
d84d3e656e
4 files changed
+159
-6
No files matched your search
+19
-6
@@ -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<Server> {
|
||||
|
||||
// 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<Server> {
|
||||
|
||||
// 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;
|
||||
|
||||
Reference in new issue
Block a user