Admin user management, password reset by email, and the Ultimo Email name

Branding: the page titles and app name are now "Ultimo Email".

Admin panel (now two columns with a divider):
- Users: search by login or by a mail account's address or name (results
  only, nothing listed until something is typed). A user opens a window to
  change their quota, block/unblock them, or delete them; block and delete ask
  for confirmation, and an admin cannot do either to their own account.
- Blocking (users.blocked_at, migration 0019) refuses sign-in with a clear
  message and revokes every session; a new user.signed_out event sends the
  user's open tabs to the sign-in screen at once. Any "not signed in" answer
  now does the same, not only /auth/me. Deleting removes mail accounts (sync
  stops), plugin rows (cleared inside the user's RLS context, since plugin
  tables have no FK to users), blobs, the search index, sessions and the user.
- Outgoing system mail (migration 0020): SMTP server, port, security, login,
  password (vault-encrypted, never sent back), From address and the public
  address reset links point to, plus a "Send test" that reports the server's
  error.

Password reset:
- "Forgot password?" on the sign-in page asks for the user name and always
  answers "If this account exists you will receive an email to your recovery
  email address"; the mail goes out after the response, so neither the reply
  nor its timing reveals an account, and it is capped at 3 per hour.
- The emailed link (token in the URL fragment, single use, 30 minutes) opens a
  page to set a new password. With 2-step verification on, the code is checked
  before anything changes; five wrong codes burn the link.
- Settings > Profile: the recovery email can be added, changed or removed,
  confirmed with the current password, which must be typed — autofill and
  paste are refused (TypedPasswordInput).

Also adds frontend/icons/ultimo-logo-bimi.svg, an SVG Tiny PS version of the
logo for a BIMI record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 20:16:27 +02:00
co-authored by Claude Opus 5.5
parent 8dc60dbf5c
commit 0ddc0cb001
32 changed files with 2267 additions and 87 deletions
+68
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import uuid
from typing import Literal
from pydantic import BaseModel, Field
@@ -47,6 +48,23 @@ class PasswordResetRequestIn(BaseModel):
class PasswordResetIn(BaseModel):
token: str = Field(min_length=1)
password: str = Field(min_length=8, max_length=1024)
totp: str | None = None # required when the account has 2FA enabled
class PasswordResetCheckIn(BaseModel):
token: str = Field(min_length=1)
class PasswordResetCheckOut(BaseModel):
valid: bool
# Tells the page to expect the 2FA step; only the link's holder learns it.
totp_required: bool = False
class RecoveryEmailIn(BaseModel):
password: str = Field(min_length=1, max_length=1024)
# None (or blank) removes the recovery address.
recovery_email: str | None = Field(default=None, max_length=320)
class UserOut(BaseModel):
@@ -79,5 +97,55 @@ class AdminSettingsIn(BaseModel):
default_quota_bytes: int | None = Field(default=None, gt=0)
class AdminMailOut(BaseModel):
smtp_host: str
smtp_port: int
smtp_security: str
smtp_username: str
# The password itself never leaves the server.
has_password: bool
smtp_from: str
public_url: str
# Host, From address and public address are all set: reset mail can go out.
configured: bool
class AdminMailIn(BaseModel):
"""Merge semantics: omitted fields are left as they are."""
smtp_host: str | None = Field(default=None, max_length=255)
smtp_port: int | None = Field(default=None, ge=1, le=65535)
smtp_security: Literal["starttls", "ssl", "none"] | None = None
smtp_username: str | None = Field(default=None, max_length=320)
# Omitted keeps the stored password; an empty string removes it.
smtp_password: str | None = Field(default=None, max_length=1024)
smtp_from: str | None = Field(default=None, max_length=320)
public_url: str | None = Field(default=None, max_length=500)
class AdminMailTestIn(BaseModel):
to: str = Field(min_length=3, max_length=320)
class AdminUserOut(BaseModel):
id: uuid.UUID
handle: str
is_admin: bool
# ISO timestamp while blocked; null otherwise.
blocked_at: str | None
quota_bytes: int
used_bytes: int
created_at: str
# The user's connected mail accounts, so the admin can tell who this is.
accounts: list[str]
class AdminUserPatch(BaseModel):
"""Merge semantics: omitted fields are left as they are."""
quota_bytes: int | None = Field(default=None, gt=0)
blocked: bool | None = None
class MessageOut(BaseModel):
status: str = "ok"