mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-25 09:47:59 +00:00
Add default organization, admin user, and groups for improved initial setup
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/968fdfce-22ac-46ff-b88e-4e0fa2f12ef0.jpg
This commit is contained in:
+56
-1
@@ -180,7 +180,62 @@ export class MemStorage implements IStorage {
|
|||||||
name: "Default Organization",
|
name: "Default Organization",
|
||||||
isActive: true
|
isActive: true
|
||||||
};
|
};
|
||||||
this.createOrganization(defaultOrg);
|
const organization = this.createOrganization(defaultOrg);
|
||||||
|
|
||||||
|
// Create a sample admin user with fixed ID to properly reference it
|
||||||
|
let adminUser: User;
|
||||||
|
const existingAdmin = Array.from(this.usersMap.values()).find(user => user.username === "admin");
|
||||||
|
if (existingAdmin) {
|
||||||
|
adminUser = existingAdmin;
|
||||||
|
} else {
|
||||||
|
adminUser = {
|
||||||
|
id: "1",
|
||||||
|
username: "admin",
|
||||||
|
password: "hashed_password", // This would be properly hashed in production
|
||||||
|
email: "admin@example.com",
|
||||||
|
fullName: "System Admin",
|
||||||
|
role: "admin",
|
||||||
|
organizationId: organization.id,
|
||||||
|
createdAt: new Date()
|
||||||
|
};
|
||||||
|
this.usersMap.set(1, adminUser);
|
||||||
|
this.userIdCounter = 2; // Ensure the next ID is after our fixed one
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create sample groups
|
||||||
|
const adminGroup: InsertGroup = {
|
||||||
|
name: "Administrators",
|
||||||
|
description: "Group for administrators with full system access",
|
||||||
|
isActive: true,
|
||||||
|
createdBy: adminUser.id,
|
||||||
|
parentGroupId: null
|
||||||
|
};
|
||||||
|
const adminsGroup = this.createGroup(adminGroup);
|
||||||
|
|
||||||
|
const dnsManagersGroup: InsertGroup = {
|
||||||
|
name: "DNS Managers",
|
||||||
|
description: "Group for users who can manage DNS records",
|
||||||
|
isActive: true,
|
||||||
|
createdBy: adminUser.id,
|
||||||
|
parentGroupId: null
|
||||||
|
};
|
||||||
|
const dnsGroup = this.createGroup(dnsManagersGroup);
|
||||||
|
|
||||||
|
// Add the admin user to the administrators group
|
||||||
|
this.addGroupMember({
|
||||||
|
groupId: adminsGroup.id,
|
||||||
|
memberId: adminUser.id,
|
||||||
|
memberType: "user",
|
||||||
|
addedBy: adminUser.id
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add the organization to the DNS managers group
|
||||||
|
this.addGroupMember({
|
||||||
|
groupId: dnsGroup.id,
|
||||||
|
memberId: organization.id,
|
||||||
|
memberType: "organization",
|
||||||
|
addedBy: adminUser.id
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
|
|||||||
Reference in New Issue
Block a user