Files
CIAgent/apps/api/app/models/pending_provisioning.py
T
sakshamandClaude Sonnet 5 56b4a5404e Add pending account provisioning for demoing to not-yet-existing accounts
An admin can now queue up an email address in advance (POST/GET/DELETE
/system/pending-provisioning) with a source user and an optional admin
flag. The moment that email actually verifies a real account - not raw
registration, which proves nothing about ownership - it gets a deep copy
of the source user's per-user API keys and every company they own
(company profile, aliases, competitors, monitor config, sources, source
documents, monitoring runs, reports, snapshots, detected changes, and
enrichment - not just the company row), plus an email notification
destination for its own address linked to the copied companies.

The clone logic (_copy_row/_clone_company in provisioning_service.py) is
generic over every table it touches via column introspection, so it
doesn't need hand-maintained field lists per model.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-08-06 18:47:29 -04:00

32 lines
1.3 KiB
Python

"""Lets an admin pre-configure what a not-yet-existing account should get
the moment someone verifies their email with a matching address - copies
of another user's per-user API keys and companies (with their full data:
sources, enrichment, reports, snapshots, etc.), an email notification
destination for the new account's own address, and optionally an admin
promotion. Built for demoing the app to people who don't have accounts
yet without hand-entering everything for them after the fact.
Applied at email-verification time, not raw registration, since
registering an email address doesn't prove you own it - see
auth_service.verify_email / provisioning_service.apply_if_pending.
"""
from __future__ import annotations
import uuid
from sqlalchemy import Boolean, ForeignKey, String
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
class PendingProvisioning(Base, UUIDPrimaryKeyMixin, TimestampMixin):
__tablename__ = "pending_provisionings"
email: Mapped[str] = mapped_column(String(320), unique=True, index=True)
source_user_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("users.id", ondelete="CASCADE"), index=True
)
make_admin: Mapped[bool] = mapped_column(Boolean, default=False)