-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_admin_user.py
More file actions
44 lines (38 loc) · 1.33 KB
/
create_admin_user.py
File metadata and controls
44 lines (38 loc) · 1.33 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
"""
Create admin users for testing different admin levels
"""
import uuid
from sqlalchemy.orm import Session
from app.db import SessionLocal
from app.models.users.models import User, UserRole
from app.auth.password import hash_password
def create_admin_user():
"""Create an admin user for testing"""
with SessionLocal() as db:
# Check if admin user already exists
existing_admin = db.query(User).filter(User.email == "admin@example.com").first()
if existing_admin:
print(f"Admin user already exists: {existing_admin.email}")
return existing_admin.id
# Create admin user
admin_user = User(
id=str(uuid.uuid4()),
email="admin@example.com",
password_hash=hash_password("AdminPass123!"),
first_name="Admin",
last_name="User",
role=UserRole.TENANT_ADMIN.value,
tenant_id="default",
is_active=True,
email_verified=True
)
db.add(admin_user)
db.commit()
db.refresh(admin_user)
print(f"Created admin user: {admin_user.email}")
print(f"Password: AdminPass123!")
print(f"Role: {admin_user.role}")
print(f"Tenant ID: {admin_user.tenant_id}")
return admin_user.id
if __name__ == "__main__":
create_admin_user()