mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Ensure the admin user always has full access to manage the application
Fixes admin role assignment, adds SQL scripts for manual correction, and provides debugging tools for production issues. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 4b008663-bd72-492b-b0b6-fa252367e730 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/4b008663-bd72-492b-b0b6-fa252367e730/nHdBv6m
This commit is contained in:
1 parent
a1ff814f6b
commit
87722d8132
6 files changed
+180
No files matched your search
@@ -331,6 +331,17 @@ export class DatabaseStorage implements IStorage {
|
||||
async initializeDefaults(): Promise<{ defaultAdminCredentials?: { username: string; password: string } }> {
|
||||
const existingUsers = await this.getAllUsers();
|
||||
|
||||
// FORCE ADMIN ROLE CORRECTION - Production fix
|
||||
const adminUsers = existingUsers.filter(u => u.username === 'admin');
|
||||
for (const adminUser of adminUsers) {
|
||||
if (adminUser.role !== 'administrator') {
|
||||
console.log(`🔧 FIXING ADMIN ROLE: User ID ${adminUser.id} role "${adminUser.role}" -> "administrator"`);
|
||||
await db.update(users)
|
||||
.set({ role: 'administrator' })
|
||||
.where(eq(users.id, adminUser.id));
|
||||
}
|
||||
}
|
||||
|
||||
if (existingUsers.length === 0) {
|
||||
// Create default store
|
||||
const defaultStore = await this.createStore({
|
||||
|
||||
Reference in new issue
Block a user