Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
"""Abstract base class for user service."""
from abc import ABC, abstractmethod
from collections.abc import Sequence
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_many(self, user_ids: Sequence[str]) -> dict[str, UserDTO]:
"""Get several users at once.
Args:
user_ids: The user IDs to look up. Duplicates are collapsed.
Returns:
A dict keyed by user_id; ids with no matching user are absent.
"""
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
LastAdministratorError: If demoting or deactivating this user would leave the
instance with no active administrator
"""
pass
@abstractmethod
def delete(self, user_id: str) -> None:
"""Delete user.
Args:
user_id: The user ID
Raises:
ValueError: If user not found
LastAdministratorError: If deleting this user would leave the instance with no
active administrator
"""
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 has_single_user_work(self) -> bool:
"""Whether work made in single-user mode exists that no signed-in account sees.
Returns:
True if the internal `system` account owns a project, wildcard, private template or private font
"""
pass
@abstractmethod
def count_admins(self) -> int:
"""Count active admin users.
Returns:
The number of active admin users
"""
pass