opencode ergebnis V0.1
This commit is contained in:
1 parent
61d86a3d83
commit
7e498ebc3f
71 files changed
+28982
-46
No files matched your search
@@ -0,0 +1,29 @@
|
||||
"""
|
||||
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)
|
||||
Reference in new issue
Block a user