28 lines
659 B
Python
28 lines
659 B
Python
import sys
|
|
from pathlib import Path
|
|
project_root = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
from src.database.session import db_manager
|
|
from src.database.repositories import UserRepository
|
|
from src.auth.service import AuthService
|
|
|
|
db_manager.initialize()
|
|
session = db_manager.get_session()
|
|
|
|
try:
|
|
user_repo = UserRepository(session)
|
|
auth_service = AuthService(user_repo)
|
|
|
|
user = auth_service.create_user_with_hashed_password(
|
|
username="admin",
|
|
password="admin1234",
|
|
role="Admin"
|
|
)
|
|
|
|
print(f"Admin user created: {user.username}")
|
|
finally:
|
|
session.close()
|
|
db_manager.close()
|
|
|