mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Update user roles and production authentication handling
Refactor route registration to conditionally import production-specific local authentication logic and update user role enum to include 'directeur'. 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/yF4FWrX
This commit is contained in:
1 parent
e782580ab8
commit
91ae0bebe7
1 file changed
+8
-4
+8
-4
@@ -880,14 +880,16 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
firstName: z.string().optional(),
|
||||
lastName: z.string().optional(),
|
||||
password: z.string().min(1, "Le mot de passe est obligatoire"),
|
||||
role: z.enum(['admin', 'manager', 'employee']).optional(),
|
||||
role: z.enum(['admin', 'directeur', 'manager', 'employee']).optional(),
|
||||
});
|
||||
|
||||
const userData = createUserSchema.parse(req.body);
|
||||
|
||||
// Hash password if provided (for local auth)
|
||||
if (userData.password) {
|
||||
const { hashPassword } = await import("./localAuth");
|
||||
// Import from the correct auth module based on environment
|
||||
const authModule = process.env.NODE_ENV === 'production' ? "./localAuth.production" : "./localAuth";
|
||||
const { hashPassword } = await import(authModule);
|
||||
userData.password = await hashPassword(userData.password);
|
||||
}
|
||||
|
||||
@@ -932,7 +934,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Schema utilisateur SANS champs obligatoires pour résoudre le problème de production
|
||||
const updateUserSchema = z.object({
|
||||
username: z.string().optional(),
|
||||
role: z.enum(['admin', 'manager', 'employee']).optional(),
|
||||
role: z.enum(['admin', 'directeur', 'manager', 'employee']).optional(),
|
||||
firstName: z.union([z.string(), z.literal("")]).optional(),
|
||||
lastName: z.union([z.string(), z.literal("")]).optional(),
|
||||
email: z.union([z.string().email(), z.literal("")]).optional(),
|
||||
@@ -943,7 +945,9 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
// Hash password if provided
|
||||
if (userData.password) {
|
||||
const { hashPassword } = await import("./localAuth");
|
||||
// Import from the correct auth module based on environment
|
||||
const authModule = process.env.NODE_ENV === 'production' ? "./localAuth.production" : "./localAuth";
|
||||
const { hashPassword } = await import(authModule);
|
||||
userData.password = await hashPassword(userData.password);
|
||||
// Mark password as changed
|
||||
(userData as any).passwordChanged = true;
|
||||
|
||||
Reference in new issue
Block a user