Spaces:
Sleeping
Sleeping
File size: 885 Bytes
93917f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
class CognitiveAuthManager:
"""Minimal authentication manager used for tests."""
def __init__(self):
self._users = {}
def register_user(self, username: str, password: str, metadata: dict | None = None) -> str:
"""Register a new user and return a pseudo cocoon id."""
if username in self._users:
raise ValueError("User already exists")
self._users[username] = {"password": password, "metadata": metadata or {}}
return f"cocoon_{username}"
def validate_user(self, username: str, password: str) -> bool:
"""Validate credentials for a user."""
return self._users.get(username, {}).get("password") == password
def collapse_user_node(self, username: str) -> bool:
"""Remove a user and return True if removed."""
return self._users.pop(username, None) is not None
|