-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_tenant_admin_user.py
More file actions
45 lines (39 loc) · 1.57 KB
/
create_tenant_admin_user.py
File metadata and controls
45 lines (39 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Create a tenant admin user for testing the 3-tier system
"""
import uuid
from sqlalchemy.orm import Session
from app.db import SessionLocal
from app.models.users.models import User
from app.auth.password import hash_password
def create_tenant_admin_user():
"""Create a tenant admin user for testing"""
with SessionLocal() as db:
# Check if tenant admin user already exists
existing_tenant_admin = db.query(User).filter(User.email == "tenant-admin@example.com").first()
if existing_tenant_admin:
print(f"Tenant admin user already exists: {existing_tenant_admin.email}")
return existing_tenant_admin.id
# Create tenant admin user with role "tenant_admin"
# This should map to tenant_admin in the frontend
tenant_admin_user = User(
id=str(uuid.uuid4()),
email="tenant-admin@example.com",
password_hash=hash_password("TenantAdmin123!"),
first_name="Tenant",
last_name="Admin",
role="tenant_admin", # This should map to frontend tenant_admin
tenant_id="default",
is_active=True,
email_verified=True
)
db.add(tenant_admin_user)
db.commit()
db.refresh(tenant_admin_user)
print(f"Created tenant admin user: {tenant_admin_user.email}")
print(f"Password: TenantAdmin123!")
print(f"Role: {tenant_admin_user.role}")
print(f"Tenant ID: {tenant_admin_user.tenant_id}")
return tenant_admin_user.id
if __name__ == "__main__":
create_tenant_admin_user()