user_service
Service managing user domain state mutations and user account operations.
- class bedrock_server_manager.services.user_service.UserService(state: AppState, storage: Storage, revoke_connections: Callable[[str], Awaitable[None]] | None = None, credentials_changed: Callable[[str], Awaitable[None]] | None = None, security_event: Callable[[str, str], Awaitable[None]] | None = None)
Handle domain logic and mutations for user state.
- get_user_state(username: str) UserInfoState | None
Return a user state snapshot.
- async list_users() list[UserInfoState]
Return all users from persistent storage.
- async change_password(username: str, current_password: str, new_password: str, *, keep_session_id: str | None = None) bool
Verify current password and update hashed password for a user.
- async reset_password(username: str, new_password: str) bool
Reset hashed password for a user without verifying old password.
- async create_registration_token(role: str, ttl_seconds: int = 86400) str
Generate and persist a new registration token.
- async validate_registration_token(token: str) bool
Return True if a registration token exists and has not expired.
- async register_or_update_user(username: str, role: str | None = None, theme: str | None = None, is_active: bool | None = None, full_name: str | None | Unset = Unset.VALUE, email: str | None | Unset = Unset.VALUE, user_id: int | None = None) UserInfoState
Register or updates a user state record and marks dirty state.
- async update_account(*, action: Literal['delete', 'disable', 'enable', 'role', 'theme', 'profile'], user_id: int | None = None, username: str | None = None, values: AccountPatch | None = None, actor_id: int | None = None) UserInfoState | None
Commit an account mutation and its audit entry before publishing state.
- async create_account(username: str, hashed_password: str, *, token: str | None = None, first_admin: bool = False) UserInfoState | None
Consume registration and publish the new account only after commit.