mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
Make user creation and deletion more robust and prevent data loss
Update user schema to make username and password mandatory, adjust email validation, and handle foreign key constraints during user deletion, including updating the database_backups table. 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/vetH0Gp
This commit is contained in:
1 parent
7618fb1643
commit
e7fb2c66f1
9 files changed
+152
-4
No files matched your search
+3
-2
@@ -877,10 +877,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Schema création utilisateur SANS champs obligatoires pour résoudre le problème de production
|
||||
const createUserSchema = z.object({
|
||||
id: z.string().optional(),
|
||||
email: z.string().email().optional(),
|
||||
username: z.string().min(1, "L'identifiant est obligatoire"),
|
||||
email: z.union([z.string().email(), z.literal("")]).optional(),
|
||||
firstName: z.string().optional(),
|
||||
lastName: z.string().optional(),
|
||||
password: z.string().optional(),
|
||||
password: z.string().min(1, "Le mot de passe est obligatoire"),
|
||||
role: z.enum(['admin', 'manager', 'employee']).optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -419,6 +419,18 @@ export class DatabaseStorage implements IStorage {
|
||||
.update(nocodbConfig)
|
||||
.set({ createdBy: adminUserId })
|
||||
.where(eq(nocodbConfig.createdBy, id));
|
||||
|
||||
// Update database backups if the table exists (production feature)
|
||||
try {
|
||||
await tx.execute(sql`
|
||||
UPDATE database_backups
|
||||
SET created_by = ${adminUserId}
|
||||
WHERE created_by = ${id}
|
||||
`);
|
||||
} catch (error) {
|
||||
// Table might not exist in development, ignore the error
|
||||
console.log('Note: database_backups table not found or accessible');
|
||||
}
|
||||
|
||||
// Update role assignments made BY this user (assignedBy field)
|
||||
await tx
|
||||
|
||||
Reference in new issue
Block a user