chore: import upstream snapshot with attribution
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
build container image / cpu (push) Has been cancelled
build container image / cuda (push) Has been cancelled
build container image / rocm (push) Has been cancelled
frontend checks / frontend-checks (push) Has been cancelled
frontend tests / frontend-tests (push) Has been cancelled
lfs checks / lfs-check (push) Has been cancelled
python checks / python-checks (push) Has been cancelled
python tests / py3.12: macos-default (push) Has been cancelled
python tests / py3.11: windows-cpu (push) Has been cancelled
python tests / py3.12: windows-cpu (push) Has been cancelled
python tests / py3.11: linux-cpu (push) Has been cancelled
typegen checks / typegen-checks (push) Has been cancelled
uv lock checks / uv-lock-checks (push) Has been cancelled
openapi checks / openapi-checks (push) Has been cancelled
python tests / py3.11: macos-default (push) Has been cancelled
python tests / py3.12: linux-cpu (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
"""Abstract base class for user service."""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from invokeai.app.services.users.users_common import UserCreateRequest, UserDTO, UserUpdateRequest
|
||||
|
||||
|
||||
class UserServiceBase(ABC):
|
||||
"""High-level service for user management."""
|
||||
|
||||
@abstractmethod
|
||||
def create(self, user_data: UserCreateRequest, strict_password_checking: bool = True) -> UserDTO:
|
||||
"""Create a new user.
|
||||
|
||||
Args:
|
||||
user_data: User creation data
|
||||
strict_password_checking: If True (default), passwords must meet strength requirements.
|
||||
If False, any non-empty password is accepted.
|
||||
|
||||
Returns:
|
||||
The created user
|
||||
|
||||
Raises:
|
||||
ValueError: If email already exists or (when strict) password is weak
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get(self, user_id: str) -> UserDTO | None:
|
||||
"""Get user by ID.
|
||||
|
||||
Args:
|
||||
user_id: The user ID
|
||||
|
||||
Returns:
|
||||
UserDTO if found, None otherwise
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_by_email(self, email: str) -> UserDTO | None:
|
||||
"""Get user by email.
|
||||
|
||||
Args:
|
||||
email: The email address
|
||||
|
||||
Returns:
|
||||
UserDTO if found, None otherwise
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def update(self, user_id: str, changes: UserUpdateRequest, strict_password_checking: bool = True) -> UserDTO:
|
||||
"""Update user.
|
||||
|
||||
Args:
|
||||
user_id: The user ID
|
||||
changes: Fields to update
|
||||
strict_password_checking: If True (default), passwords must meet strength requirements.
|
||||
If False, any non-empty password is accepted.
|
||||
|
||||
Returns:
|
||||
The updated user
|
||||
|
||||
Raises:
|
||||
ValueError: If user not found or (when strict) password is weak
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def delete(self, user_id: str) -> None:
|
||||
"""Delete user.
|
||||
|
||||
Args:
|
||||
user_id: The user ID
|
||||
|
||||
Raises:
|
||||
ValueError: If user not found
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def authenticate(self, email: str, password: str) -> UserDTO | None:
|
||||
"""Authenticate user credentials.
|
||||
|
||||
Args:
|
||||
email: User email
|
||||
password: User password
|
||||
|
||||
Returns:
|
||||
UserDTO if authentication successful, None otherwise
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def has_admin(self) -> bool:
|
||||
"""Check if any admin user exists.
|
||||
|
||||
Returns:
|
||||
True if at least one admin user exists, False otherwise
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def create_admin(self, user_data: UserCreateRequest, strict_password_checking: bool = True) -> UserDTO:
|
||||
"""Create an admin user (for initial setup).
|
||||
|
||||
Args:
|
||||
user_data: User creation data
|
||||
strict_password_checking: If True (default), passwords must meet strength requirements.
|
||||
If False, any non-empty password is accepted.
|
||||
|
||||
Returns:
|
||||
The created admin user
|
||||
|
||||
Raises:
|
||||
ValueError: If admin already exists or (when strict) password is weak
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def list_users(self, limit: int = 100, offset: int = 0) -> list[UserDTO]:
|
||||
"""List all users.
|
||||
|
||||
Args:
|
||||
limit: Maximum number of users to return
|
||||
offset: Number of users to skip
|
||||
|
||||
Returns:
|
||||
List of users
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_admin_email(self) -> str | None:
|
||||
"""Get the email address of the first active admin user.
|
||||
|
||||
Returns:
|
||||
Email address of the first active admin, or None if no admin exists
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def count_admins(self) -> int:
|
||||
"""Count active admin users.
|
||||
|
||||
Returns:
|
||||
The number of active admin users
|
||||
"""
|
||||
pass
|
||||
Reference in New Issue
Block a user