Skip to content

Provisioning

App-supplied columns for new-user creation. new_user_fields on CRUDAuth receives this context and returns your own columns to set at signup, on both the password and OAuth paths; new_user_defaults is the constant-only shortcut. See the registration guide for usage.

crudauth.provisioning.NewUserContext dataclass

NewUserContext(
    email: str,
    username: str,
    source: Literal["register", "oauth"],
    db: AsyncSession,
    register_data: dict[str, Any] | None = None,
    oauth: OAuthUserInfo | None = None,
)

What crudauth knows about a user it is about to create.

Fed to new_user_fields on both signup paths. Server-built and trusted - never the raw request body.

Attributes:

Name Type Description
email str

The new user's (canonicalized) email.

username str

The final username, after OAuth uniquification.

source Literal['register', 'oauth']

"register" for password signup, "oauth" for OAuth signup.

db AsyncSession

The active session. The callback may read from it (e.g. to resolve a default tier or assign an org by email domain) but must NOT commit - crudauth owns the transaction boundary.

register_data dict[str, Any] | None

The validated /register body (password excluded), or None on the OAuth path.

oauth OAuthUserInfo | None

The provider profile, or None on the password path.

suggested_name property

suggested_name: str

A display name to default to: the OAuth name, else the email local-part, else the username - so it stays useful across email and email-less shapes.