Files
2026-10-23 00:05:06 +02:00

30 lines
938 B
Python

"""
Accounts Service - Geschäftslogik für Accounts
"""
from cmbnet.models.accounts import AccountModel
from cmbnet.auth import verify_password, hash_password
class AccountsService:
@staticmethod
def verify_account_password(account, password):
"""Überprüft Passwort gegen Account"""
if not account:
return False
return verify_password(account['password_hash'], password)
@staticmethod
def has_role(account, roles):
"""Prüft, ob Account eine der angegebenen Rollen hat"""
if isinstance(roles, str):
roles = [roles]
if not account:
return False
return account['role'] in roles
@staticmethod
def create_account(tenant_id, name, password, role):
"""Erstellt einen neuen Account"""
password_hash = hash_password(password)
return AccountModel.create(tenant_id, name, password_hash, role)