admin panel migration to jinja

This commit is contained in:
2025-10-25 07:31:44 +02:00
parent 13ae656a49
commit 1a43a4250c
21 changed files with 1788 additions and 1599 deletions

View File

@@ -159,6 +159,52 @@ class AuthManager:
raise AdminRequiredException()
return current_user
def require_vendor(self, current_user: User):
"""
Require vendor role (vendor or admin).
Vendors and admins can access vendor areas.
Args:
current_user: Current authenticated user
Returns:
User: The user if they have vendor or admin role
Raises:
InsufficientPermissionsException: If user is not vendor or admin
"""
if current_user.role not in ["vendor", "admin"]:
from app.exceptions import InsufficientPermissionsException
raise InsufficientPermissionsException(
message="Vendor access required",
required_permission="vendor"
)
return current_user
def require_customer(self, current_user: User):
"""
Require customer role (customer or admin).
Customers and admins can access customer account areas.
Args:
current_user: Current authenticated user
Returns:
User: The user if they have customer or admin role
Raises:
InsufficientPermissionsException: If user is not customer or admin
"""
if current_user.role not in ["customer", "admin"]:
from app.exceptions import InsufficientPermissionsException
raise InsufficientPermissionsException(
message="Customer account access required",
required_permission="customer"
)
return current_user
def create_default_admin_user(self, db: Session):
"""Create default admin user if it doesn't exist."""
admin_user = db.query(User).filter(User.username == "admin").first()