Help us shape the future of Go! Take the 2026 Go Developer Survey

site

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 76 Imported by: 0

Documentation

Overview

Package site implements the /site surface: the API of the frontend SPA, authenticated by the session cookie.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditLog

type AuditLog interface {
	Licensed() bool
	// Entries returns up to limit entries matching the filter, newest first, preceding
	// the cursor entry id (0 = from the newest), and the next page's cursor (0 = last page).
	Entries(ctx context.Context, s *ent.Scoped, f events.AuditFilter, cursor int64, limit int) ([]*ent.AuditEntry, int64, error)
	// ExportCSV streams the entries matching the filter, newest first, as CSV.
	ExportCSV(ctx context.Context, s *ent.Scoped, f events.AuditFilter, w io.Writer) error
	// RetentionLicensed reports whether the retention window may be set (ADR 0014).
	RetentionLicensed() bool
}

AuditLog is the read seam of the Enterprise Audit log (ADR 0022), implemented by ee/audit. Core knows only this interface: without a license Licensed is false and the page answers 402.

type Deps

type Deps struct {
	Accounts *accounts.Accounts
	// Deletion is the Workspace deletion cycle (ADR 0043).
	Deletion *workspacedeletion.Module
	// Instance is the Instance state no Workspace owns (ADR 0032).
	Instance *instance.Module
	// Attempts counts failed logins and password-reset mails per account (ADR
	// 0025); login and forgot-password share it.
	Attempts       *accounts.Attempts
	OAuth          *oauthserver.Service
	Bus            *events.Bus
	Webhooks       *webhooks.Module
	Outbound       *outbound.Module
	Segments       *segments.Module
	EventLog       *eventlog.Module
	Contacts       *contacts.Module
	Erasure        *erasure.Module
	Tags           *tags.Module
	Templates      *templates.Module
	BrandKit       *brandkit.Module
	Automations    *automations.Module
	Rules          *rules.Module
	Broadcasts     *broadcasts.Module
	Welcome        WelcomeEnqueuer
	SysMail        SystemMailEnqueuer
	SendingDomains *sendingdomains.Module
	JoinDomains    *joindomains.Module
	Integrations   *integrations.Module
	Tokens         *authtoken.Signer
	Tracker        *tracking.Tracker
	AppURL         string
	Audit          AuditLog
	AbuseWatch     abusewatch.Watch
	// SupportEmail is where a suspended Workspace's owner appeals (SPHERICON_SUPPORT_EMAIL).
	SupportEmail string
	// MCPURL is the public origin of the MCP endpoint (config.MCPOrigin).
	MCPURL    string
	Analytics *analytics.Module
	// Sessions issues the session cookie on login (ADR 0020). The composition
	// root (server.New) builds it from the instance secret and SPHERICON_SESSION_TTL.
	Sessions *auth.Sessions
	// SecondFactor enrolls and verifies a User's TOTP Second factor (ADR 0020).
	SecondFactor *secondfactor.Module
	// Passkeys registers a User's Passkeys (ADR 0052).
	Passkeys *secondfactor.Passkeys
	// Clock is the time the site session's expiry and a Two-factor requirement's
	// grace are checked against (ADR 0020); nil means time.Now. Tests inject one to
	// move past a session's lifetime or a grace period.
	Clock func() time.Time
	// AccountLink mints the Owner's Account link token; nil when the installation is
	// not configured for it, which leaves the operation answering 404.
	AccountLink *accountlink.Link
	// Holds reads a Workspace's standing: the same module, so the same license gate,
	// the send path applies (ADR 0009).
	Holds *holds.Holds
	// RequireEmailVerification is the email verification gate (ADR 0030): when false,
	// registration takes a password and yields a Verified User at once, and login
	// checks no verification.
	RequireEmailVerification bool
	// SignupOpen is SPHERICON_SIGNUP_OPEN (ADR 0042): when false, register answers 403.
	SignupOpen bool
	// SignupSurvey is the Sign-up survey module (built with signupsurvey.Enabled).
	SignupSurvey *signupsurvey.Module
	// Signin is the Sign-in providers the Instance enabled (ADR 0048); none enabled when
	// no provider is configured.
	Signin *signin.Providers
}

Deps is everything the /site handlers are built from. The domain modules are the shared singletons the composition root registers once, so /site and /api cannot diverge on how a module is constructed.

type Handlers

type Handlers struct {
	// contains filtered or unexported fields
}

func NewHandlers

func NewHandlers(d Deps) *Handlers

SiteAnalyticsClicksByLink maps the analytics module's Clicks by link report onto the DTO.

func (*Handlers) SiteAnalyticsEvents

SiteAnalyticsEvents maps the analytics module's Events report onto the DTO.

func (*Handlers) SiteAnalyticsNewPeople

SiteAnalyticsNewPeople maps the New people report onto the DTO.

func (*Handlers) SiteAnalyticsOpensByHour

SiteAnalyticsOpensByHour maps the analytics module's Opens by hour report onto the DTO.

func (*Handlers) SiteAnalyticsOverview

SiteAnalyticsOverview maps the analytics module's Overview onto the DTO.

func (*Handlers) SiteAnalyticsSubscribedPeople

SiteAnalyticsSubscribedPeople maps the Subscribed people report onto the DTO.

func (*Handlers) SiteAuditExport

SiteAuditExport downloads the whole Audit log as CSV, newest first. Same access as the list: owner and admin only, 402 without an Enterprise license. It takes the same filter as SiteAuditList, so an export matches what the page shows.

func (*Handlers) SiteAuditGetRetention

SiteAuditGetRetention reads the Audit log retention window. Owner and admin only; 402 without the Enterprise retention license.

func (*Handlers) SiteAuditList

SiteAuditList shows the Workspace's Audit log, newest first. Owner and admin only; an instance without an Enterprise license answers 402 (ADR 0014, ADR 0022).

func (*Handlers) SiteAuditSetRetention

SiteAuditSetRetention sets or clears the Audit log retention window and records the change as a `workspace.update` Audit entry. Owner and admin only.

func (*Handlers) SiteAuthConfirmEmailChange

SiteAuthConfirmEmailChange applies a requested email change once the new address is confirmed via the token sent to it. Public: the link may be opened from a browser without a session. The change ends every session of the User (ADR 0020); when the confirming request carries a valid session of that same User, it continues under a fresh token in the same response. The link alone never signs anyone in.

func (*Handlers) SiteAuthForgotPassword

SiteAuthForgotPassword mints a reset token and emails a link. It answers 202 whether or not the address matches an account and whether or not the per-address budget is spent, so the endpoint cannot be used to enumerate registered emails (the per-IP cap answers 429 in the rate limit middleware, before this runs). Every request does the same work: take a slot of the address's budget in one atomic step, look the address up, mint a token and enqueue a mail job. Only a known address that was granted a slot gets its mail delivered; for the others the job is a no-send one, so response time does not leak existence either.

func (*Handlers) SiteAuthLogin

SiteAuthLogin is the one route that starts a session (ADR 0020). It consults the Login throttle first (ADR 0025): while the address's delay runs it answers 429 even for a correct password, else guessing until one attempt succeeds would skip the delay. An unknown email, a wrong password and a User without a password all answer the same 401, after the same password hash work, and all count as a failure of the address. A success resets the counter, sets the session cookie and is recorded as `user.login` in each of the User's Workspaces (ADR 0022).

A User with an active Second factor gets a challenge instead of the cookie, and the counter is not reset: only the second step resets it, else knowing the password would buy a fresh round of code guesses on every login.

func (*Handlers) SiteAuthLogout

SiteAuthLogout ends the session on this browser by clearing its cookie. A token copied elsewhere stays valid until it expires or the User's epoch is bumped.

func (*Handlers) SiteAuthRegister

SiteAuthRegister creates an Unverified User from a name, an email and a password (ADR 0030): no session, no Workspace. The password is stored hashed, and the mailed token is bound to it and to the browser that registered, whose cookie the answer sets; the link trusts the password only when that browser opens it (SiteAuthVerifyEmail). The Workspace and the welcome email follow the proof.

func (*Handlers) SiteAuthResendVerification

SiteAuthResendVerification sends the verification link again to an Unverified User (ADR 0030). It answers 202 the same way for an unknown, an already verified and an unverified address, and every request does the same work (a token is minted, a mail job is queued); only an Unverified User's job delivers, the others' is a no-send one, so neither the answer nor its timing says whether the address has an account. The per-IP cap answers 429 in the rate limit middleware, before this runs.

func (*Handlers) SiteAuthResetPassword

SiteAuthResetPassword sets a new password from a reset token.

func (*Handlers) SiteAuthSecondFactor

SiteAuthSecondFactor is the second login step of a User with a Second factor (ADR 0020): the login module parses the challenge, consults the Login throttle (ADR 0025), verifies the code through the adapter and counts. A current TOTP or unused Recovery code starts the session, recorded as `user.login` like a one-step login (a Recovery code is also recorded as `user.recovery_code_use` by the module). Wrong codes count as failures of the User's address, and while its delay runs even a correct code answers 429. A bad challenge has no trusted address, so it is answered 401 without counting; the per-IP login cap still applies to the route.

func (*Handlers) SiteAuthSigninCallback

SiteAuthSigninCallback is where the provider sends the browser back. Whatever happens it answers with a redirect: to the page the flow began from with the session cookie, or to the login page with the Reason, which the SPA renders. A callback that is not for a flow this browser began (no cookie, another state) is refused before the provider is asked anything.

func (*Handlers) SiteAuthSigninNotMe

SiteAuthSigninNotMe is the link of the notice mailed after a silent link: it unlinks the identity the token names and ends every session of its User (ADR 0048). The token is the credential, so it works without a session; it works once, because once the identity is gone there is nothing left to undo.

func (*Handlers) SiteAuthSigninProviders

func (h *Handlers) SiteAuthSigninProviders(context.Context) (*siteapi.SiteSigninProviders, error)

SiteAuthSigninProviders lists the Sign-in providers the Instance enabled, for the buttons of the login and register pages (empty when none is configured).

func (*Handlers) SiteAuthSigninStart

SiteAuthSigninStart begins a provider sign-in (ADR 0048): it draws the flow, keeps it in the signed flow cookie with the `return_to` that survived validation, and redirects the browser to the provider.

func (*Handlers) SiteAuthVerifyEmail

SiteAuthVerifyEmail completes a registration from its link (ADR 0030): the token proves the address, so it stamps the Verified email, ends every earlier session, creates the User's first Workspace and sends the welcome email, then starts the session through the login issuer. The password stored at registration stays only when the request carries the registration cookie the token was minted for; any other browser must send a password, which replaces it, and without one nothing changes and the token stays valid (a mail scanner consumes nothing). The token is single use (the Verified check) and scoped to the address it was sent to: an old link never verifies a changed address.

func (*Handlers) SiteAutomationsArchive

SiteAutomationsArchive archives an automation (ADR 0049): it leaves the list and enrolls nobody, and keeps its enrollments. Active enrollments refuse it with 409.

func (*Handlers) SiteAutomationsDryRunHttpStep

SiteAutomationsDryRunHttpStep renders an HTTP step's body for a Contact and validates it; nothing is called.

func (*Handlers) SiteAutomationsGet

func (*Handlers) SiteAutomationsList

func (*Handlers) SiteAutomationsUnarchive

SiteAutomationsUnarchive restores an archived automation to the list.

func (*Handlers) SiteBrandKitGet

SiteBrandKitGet returns the Workspace's Brand kit; every member may read it.

func (*Handlers) SiteBrandKitRecreateStarterTemplates

SiteBrandKitRecreateStarterTemplates makes the starter Templates again from the saved Brand kit. Owners only.

func (*Handlers) SiteBrandKitSave

SiteBrandKitSave saves the Brand kit: the first save also makes the starter Templates. Owners only.

func (*Handlers) SiteBroadcastsArchive

SiteBroadcastsArchive archives a sent or failed broadcast (ADR 0049): it leaves the list but keeps its report, tracking and figures.

func (*Handlers) SiteBroadcastsDelete

func (*Handlers) SiteBroadcastsGet

func (*Handlers) SiteBroadcastsList

func (*Handlers) SiteBroadcastsSchedule

SiteBroadcastsSchedule schedules a draft broadcast to send at a future time.

func (*Handlers) SiteBroadcastsSend

SiteBroadcastsSend sends a draft or scheduled broadcast immediately. The state machine lives in the broadcasts module; this is the HTTP adapter.

func (*Handlers) SiteBroadcastsTestSend

SiteBroadcastsTestSend renders the broadcast with sample merge data and sends it to a single address — no recipient rows, no tracking (a token would point at a nonexistent recipient). Used to preview the rendered email.

func (*Handlers) SiteBroadcastsUnarchive

SiteBroadcastsUnarchive restores an archived broadcast to the list.

func (*Handlers) SiteContactsDelete

SiteContactsDelete is Erasure (ADR 0021): irreversible, so owner or admin only.

func (*Handlers) SiteContactsErase

SiteContactsErase is Erasure by email address (ADR 0021, a Privacy request): the one erasure module, with the signed-in User as requester. Owner or admin only, like deleting a Contact. Not-found means neither a Contact nor delivery records hold the address.

func (*Handlers) SiteContactsExport

SiteContactsExport streams the subject-access Data export of one contact (ADR 0021). Any Workspace member may export: it needs contact read access only.

func (*Handlers) SiteContactsGet

func (*Handlers) SiteContactsList

func (*Handlers) SiteContactsLookup

SiteContactsLookup answers a Privacy request's first question (ADR 0021): what the Workspace holds for an email address, as counts. It sits beside Erasure, so owner or admin only; an address nothing holds answers with zeros.

func (*Handlers) SiteCustomFieldsList

SiteCustomFieldsList returns the workspace's Custom field definitions — the typed, named attribute catalogue (ADR 0006) that feeds the segment builder. Definitions are auto-created on first sight at ingest; this is a read-only catalogue. The full set is returned in a single page (the catalogue is small and unpaginated).

func (*Handlers) SiteDomainJoinGet

SiteDomainJoinGet reads the Workspace's domain join switch. Owners only.

func (*Handlers) SiteDomainJoinSet

SiteDomainJoinSet switches the Workspace's domain join on or off. Owners only.

func (*Handlers) SiteEnrollmentsGet

func (*Handlers) SiteEnrollmentsList

func (*Handlers) SiteEventsActions

SiteEventsActions returns the distinct event actions in the workspace, sorted — used to populate the segment builder's event-condition picker.

func (*Handlers) SiteEventsList

SiteEventsList returns the workspace's events, most recent first.

SiteIdentitiesLink begins linking a provider account to the session User: the same flow as a sign-in, but the signed flow cookie also names the User the callback adds the subject to.

func (*Handlers) SiteIdentitiesList

func (h *Handlers) SiteIdentitiesList(ctx context.Context) (*siteapi.SiteLinkedIdentities, error)

SiteIdentitiesList lists the session User's Linked identities (ADR 0048).

SiteIdentitiesUnlink removes a Linked identity of the session User, unless it is the last way to sign in, ends the other sessions and reissues the acting one.

func (*Handlers) SiteInstanceAcknowledgeNotice

func (h *Handlers) SiteInstanceAcknowledgeNotice(ctx context.Context) (siteapi.SiteInstanceAcknowledgeNoticeRes, error)

SiteInstanceAcknowledgeNotice records that an Owner saw the one-time notice.

func (*Handlers) SiteInstanceGetState

func (h *Handlers) SiteInstanceGetState(ctx context.Context) (siteapi.SiteInstanceGetStateRes, error)

SiteInstanceGetState returns the Instance state to an Owner of the oldest Workspace.

func (*Handlers) SiteInstancePreviewTelemetryReport

func (h *Handlers) SiteInstancePreviewTelemetryReport(ctx context.Context) (siteapi.SiteInstancePreviewTelemetryReportRes, error)

SiteInstancePreviewTelemetryReport returns the Telemetry report exactly as the Instance would send it now, whether or not sending is on. It is the body of the same builder the daily sender uses, so the Owner reads the real payload.

func (*Handlers) SiteInstanceSetTelemetry

SiteInstanceSetTelemetry stores the Owner's Telemetry report choice; 409 while the environment decides.

func (*Handlers) SiteIntegrationsArchive

SiteIntegrationsArchive archives an integration (ADR 0049): it leaves the list and gives up the default, unless live work uses it (409). Owners and admins only.

func (*Handlers) SiteIntegrationsCreate

SiteIntegrationsCreate stores a new provider integration; credentials are encrypted at rest and never returned. Owners and admins only.

func (*Handlers) SiteIntegrationsGet

SiteIntegrationsGet returns one integration with secrets redacted.

func (*Handlers) SiteIntegrationsList

SiteIntegrationsList returns the workspace's sending-provider integrations with secrets redacted.

func (*Handlers) SiteIntegrationsRegenerateKey

SiteIntegrationsRegenerateKey gives the integration a new hook key; the old hook URL stops working at once. Owners and admins only.

func (*Handlers) SiteIntegrationsUnarchive

SiteIntegrationsUnarchive restores an archived integration to the list. It is not the default. Owners and admins only.

func (*Handlers) SiteIntegrationsUpdate

SiteIntegrationsUpdate edits an integration. Omitting config keeps the stored credentials; a supplied config must match the integration's provider kind. Within a supplied config, blank secret fields (password, secret access key) keep the stored secret rather than clearing it, since secrets are never echoed back on read — so a partial edit cannot accidentally wipe a credential.

func (*Handlers) SiteInvitationsCreate

SiteInvitationsCreate invites an email address to the workspace. Owner/admin only. The one-time accept link is returned (copy-link path) and an invite email is sent best-effort — a missing/failed mailer must not fail the invite.

func (*Handlers) SiteInvitationsDelete

SiteInvitationsDelete revokes a pending invitation. Owner/admin only.

func (*Handlers) SiteInvitationsList

SiteInvitationsList returns the workspace's pending (unaccepted) invitations.

func (*Handlers) SiteJoinDomainsAdd

SiteJoinDomainsAdd adds a pending Join domain. Owners only.

func (*Handlers) SiteJoinDomainsList

SiteJoinDomainsList lists the Workspace's Join domains. Owners only.

func (*Handlers) SiteJoinDomainsRemove

SiteJoinDomainsRemove removes a Join domain claim. Owners only.

func (*Handlers) SiteJoinDomainsVerify

SiteJoinDomainsVerify checks the TXT record live and verifies the domain. Owners only.

func (*Handlers) SiteMembershipsDelete

SiteMembershipsDelete removes a member. Owner/admin only; the last owner cannot be removed.

func (*Handlers) SiteMembershipsList

SiteMembershipsList returns the workspace's members. Any member may view them.

func (*Handlers) SiteMembershipsResetSecondFactor

SiteMembershipsResetSecondFactor resets a member's Second factor (ADR 0020): owner/admin only, owner-only for an owner's. It ends every session of the member and records `user.second_factor_reset` in this Workspace; the acting session is someone else's, so nothing is reissued. A member resets nobody, and nobody resets their own here (disabling takes a password and a code).

func (*Handlers) SiteMembershipsUpdate

SiteMembershipsUpdate changes a member's role. Owner/admin only; only an owner may grant the owner role, and the last owner can never be demoted.

func (*Handlers) SiteOAuthDecide

SiteOAuthDecide records the signed-in user's consent decision. The token the client later receives belongs to the chosen workspace, which the user must be a member of with a role that may manage API tokens: consent mints one.

func (*Handlers) SiteOAuthDescribe

SiteOAuthDescribe validates an OAuth authorization request for the consent screen (the client is untrusted: only its registered redirect URIs are honored).

func (*Handlers) SitePasskeyLoginBegin

func (h *Handlers) SitePasskeyLoginBegin(context.Context) (siteapi.SitePasskeyLoginBeginRes, error)

SitePasskeyLoginBegin answers the request options for a usernameless Passkey login and sets the ceremony cookie. It is anonymous and writes nothing (ADR 0052).

func (*Handlers) SitePasskeyLoginFinish

SitePasskeyLoginFinish logs in with the authenticator's response. It runs through the login module as its third step: the User is found by the credential id, the Login throttle is consulted for that User before anything is verified, and every other refusal (an unknown credential, a response that does not verify, a spent or expired challenge, the verification gate) is the one 401 and counts nothing. The session is issued through the one issuer, with the Passkey method: it replaces the password and the Second factor.

func (*Handlers) SitePasskeysBeginCheck

func (h *Handlers) SitePasskeysBeginCheck(ctx context.Context) (siteapi.SitePasskeysBeginCheckRes, error)

SitePasskeysBeginCheck answers the request options of a fresh Passkey check of the session User, who holds at least one Passkey, and sets the ceremony cookie.

func (*Handlers) SitePasskeysBeginRegistration

func (h *Handlers) SitePasskeysBeginRegistration(ctx context.Context) (siteapi.SitePasskeysBeginRegistrationRes, error)

SitePasskeysBeginRegistration answers the creation options for the browser and sets the ceremony cookie. It writes nothing.

func (*Handlers) SitePasskeysFinishCheck

SitePasskeysFinishCheck verifies a fresh Passkey check: the response must be made with a Passkey of the session's own User and verify against the ceremony. The acting session is reissued with the time of the check, which stands in for the password for a few minutes (identityProofTTL). Every refusal is the one 403: there is nothing to throttle, a guess cannot succeed without the private key.

func (*Handlers) SitePasskeysFinishRegistration

SitePasskeysFinishRegistration stores the Passkey once the User proves their identity (the password, or a fresh provider login) and the authenticator's response checks out. It ends the other sessions, reissues the acting one and mails the owner.

func (*Handlers) SitePasskeysList

func (h *Handlers) SitePasskeysList(ctx context.Context) (*siteapi.SitePasskeyList, error)

SitePasskeysList lists the session User's Passkeys, oldest first (ADR 0052).

func (*Handlers) SitePasskeysRemove

SitePasskeysRemove removes a Passkey of the session User once they prove their identity (the password, or a fresh provider login). It ends the other sessions, reissues the acting one and mails the owner.

func (*Handlers) SitePasskeysRename

SitePasskeysRename renames a Passkey of the session User.

func (*Handlers) SitePresetsList

func (h *Handlers) SitePresetsList(_ context.Context) ([]siteapi.SitePresetResource, error)

SitePresetsList returns the Presets the Instance offers with their params schemas.

func (*Handlers) SitePublicConfirmationsPerform

SitePublicConfirmationsPerform is the double opt-in confirmation page's button (ADR 0013): the one place a confirmation is performed.

func (*Handlers) SitePublicInvitationsAccept

SitePublicInvitationsAccept turns an invite into a Membership: it attaches an Verified User (their own session) or sets up the account (name + password), then joins them to the workspace. Link possession authorizes an address with no Verified User; a Verified User's address also needs that User's session.

func (*Handlers) SitePublicInvitationsLookup

SitePublicInvitationsLookup reveals a pending invite (workspace + email) so the public accept page can render. Session-less: the token is the authorization.

func (*Handlers) SitePublicUnsubscribesPerform

SitePublicUnsubscribesPerform is the unsubscribe page's button (ADR 0012): the same effect as POST /e/u/{token}, which stays for the mailbox one-click POST.

func (*Handlers) SiteRuleFiringsList

SiteRuleFiringsList lists a Rule's Firings, newest first.

func (*Handlers) SiteRulesActivate

SiteRulesActivate makes the Rule react to the Events recorded from now on.

func (*Handlers) SiteRulesArchive

SiteRulesArchive archives a Rule (ADR 0049): it acts on nothing and keeps its Firings.

func (*Handlers) SiteRulesCreate

SiteRulesCreate always stores a draft.

func (*Handlers) SiteRulesDeactivate

func (*Handlers) SiteRulesDelete

SiteRulesDelete purges a Rule that has no Firings; one with Firings is archived instead (409).

func (*Handlers) SiteRulesDryRun

SiteRulesDryRun reports what a stored Event would do to the Rule, writing and running nothing.

func (*Handlers) SiteRulesGet

func (*Handlers) SiteRulesList

func (*Handlers) SiteRulesUnarchive

SiteRulesUnarchive restores an archived Rule to the list, as a draft.

func (*Handlers) SiteSecondFactorConfirmEnrollment

SiteSecondFactorConfirmEnrollment activates the pending secret with the password and a valid code, returns the Recovery codes once and reissues the acting session (the epoch moved).

func (*Handlers) SiteSecondFactorDisable

SiteSecondFactorDisable removes the Second factor after the password and a current code are proven, and reissues the acting session.

func (*Handlers) SiteSecondFactorGetStatus

func (h *Handlers) SiteSecondFactorGetStatus(ctx context.Context) (*siteapi.SiteSecondFactorStatus, error)

SiteSecondFactorGetStatus answers whether the User has a Second factor, a pending enrollment, and how many Recovery codes are left (never the codes).

func (*Handlers) SiteSecondFactorRegenerateRecoveryCodes

func (h *Handlers) SiteSecondFactorRegenerateRecoveryCodes(ctx context.Context, req *siteapi.SiteRecoveryCodesInput) (siteapi.SiteSecondFactorRegenerateRecoveryCodesRes, error)

SiteSecondFactorRegenerateRecoveryCodes replaces the Recovery codes after the password is proven, and reissues the acting session.

func (*Handlers) SiteSecondFactorStartEnrollment

SiteSecondFactorStartEnrollment creates a pending TOTP secret (ADR 0020) once the password is proven: a hijacked session alone cannot enroll a factor of its own.

func (*Handlers) SiteSegmentContactsList

SiteSegmentContactsList lists the Contacts a Segment matches right now: its rule alone, like the Segment's count; Send-eligibility is subtracted only at send (ADR 0001).

func (*Handlers) SiteSegmentsArchive

SiteSegmentsArchive archives a segment (ADR 0049): it leaves the list and new work, and a sent Broadcast's report still names it. A draft or scheduled Broadcast refuses it with 409.

func (*Handlers) SiteSegmentsGet

func (*Handlers) SiteSegmentsList

func (*Handlers) SiteSegmentsPreview

SiteSegmentsPreview reports how many *deliverable* (active) contacts match a rule definition. It applies the same active filter the broadcast send path uses, so the previewed number matches what a broadcast to this segment ships.

func (*Handlers) SiteSegmentsUnarchive

SiteSegmentsUnarchive restores an archived segment to the list.

func (*Handlers) SiteSendingDomainsArchive

SiteSendingDomainsArchive archives a sending domain (ADR 0049): it leaves the list and serves no Tracking domain host. Live sends from it refuse it with 409.

func (*Handlers) SiteSendingDomainsUnarchive

SiteSendingDomainsUnarchive restores an archived sending domain and starts a DNS check.

func (*Handlers) SiteSetupChecklistGet

SiteSetupChecklistGet maps the Workspace's Setup checklist onto the DTO.

func (*Handlers) SiteSignupSurveySubmit

SiteSignupSurveySubmit stores the authenticated User's answers to the Sign-up survey and clears the "survey due" marker. The survey belongs to the User, so no Workspace is read.

func (*Handlers) SiteSuppressionsList

func (*Handlers) SiteTagsDelete

SiteTagsDelete deletes a Tag from the catalogue unless a Segment rule or an Automation step names it (ADR 0049).

func (*Handlers) SiteTagsList

func (*Handlers) SiteTagsRemove

func (*Handlers) SiteTemplatesDelete

func (*Handlers) SiteTemplatesGet

func (*Handlers) SiteTemplatesList

func (*Handlers) SiteTokensCreate

SiteTokensCreate mints a workspace API token. The full secret is returned once; only its bcrypt hash and public prefix are stored.

func (*Handlers) SiteTokensDelete

SiteTokensDelete revokes (soft-deletes) a workspace API token.

func (*Handlers) SiteTokensList

SiteTokensList returns the workspace's API tokens; a revoked one stays listed, marked by its revoked_at, so an owner sees a connector that was revoked (by hand or by reuse detection).

func (*Handlers) SiteTokensUpdate

SiteTokensUpdate renames an active workspace API token.

func (*Handlers) SiteTransactionalEmailsList

SiteTransactionalEmailsList returns the workspace's transactional send history (the Outbound messages the /api/emails surface wrote), most recent first.

func (*Handlers) SiteUserDeleteUser

SiteUserDeleteUser deletes the caller's own User at once (User deletion, ADR 0050), after the typed email, the password (through the login module's one prove path, so a wrong one is counted on the Login throttle) and, with a Second factor, a current code. The accounts operation does the rest in one transaction; this handler authenticates, proves and maps the outcomes.

SiteUserDeleteUserLink mails the one-time deletion link to a User with no password (ADR 0050): the typed email must be the User's, and the link goes to that Verified address. The token is bound to the User and their session epoch, not to the address, and works once (the deletion removes the User it names).

func (*Handlers) SiteUserEmailChange

SiteUserEmailChange requests a change of the login email. It verifies the current password, and emails a confirmation link to the NEW address (or, when that address is Taken, a notice to its owner: the answer is the same) — the change only takes effect once that link is confirmed (SiteAuthConfirmEmailChange). Returns 202.

func (*Handlers) SiteUserGetMe

func (h *Handlers) SiteUserGetMe(ctx context.Context) (*siteapi.SiteUserResource, error)

SiteUserGetMe returns the authenticated user's profile. Auth is enforced by the security handler, so SiteAuth is always present here.

func (*Handlers) SiteUserSignOutEverywhere

func (h *Handlers) SiteUserSignOutEverywhere(ctx context.Context) (*siteapi.SiteUserSignOutEverywhereNoContent, error)

SiteUserSignOutEverywhere ends every session of the authenticated user, on every device, and clears the acting browser's cookie: no session survives.

func (*Handlers) SiteUserUpdateMe

SiteUserUpdateMe updates the authenticated user's name and/or password. Email is the login identity and is not editable here. Changing the password requires the correct current password.

func (*Handlers) SiteWebhooksDelete

func (*Handlers) SiteWebhooksGet

func (*Handlers) SiteWebhooksList

func (*Handlers) SiteWebhooksRegenerateSecret

SiteWebhooksRegenerateSecret replaces the endpoint's signing secret and returns the endpoint with the new one.

func (*Handlers) SiteWebhooksTest

SiteWebhooksTest sends a sample event to the endpoint and returns what the receiver answered, at once.

SiteWorkspacesAccountLink mints the Owner's Account link token. Without the installation's configuration it answers 404 before anything else; any role but Owner is refused.

func (*Handlers) SiteWorkspacesCreate

SiteWorkspacesCreate creates a Workspace for the authenticated User, who becomes its Owner (ADR 0043). Only a Verified User may create one.

func (*Handlers) SiteWorkspacesDelete

SiteWorkspacesDelete deletes a Workspace (Owner only) after the typed name matches.

func (*Handlers) SiteWorkspacesLeave

SiteWorkspacesLeave removes the caller's own Membership (Leaving, ADR 0050). Any Role may leave; the only Owner is refused.

func (*Handlers) SiteWorkspacesList

func (h *Handlers) SiteWorkspacesList(ctx context.Context) ([]siteapi.SiteWorkspaceResource, error)

SiteWorkspacesList returns the workspaces the authenticated user is a member of.

func (*Handlers) SiteWorkspacesListDeleted

func (h *Handlers) SiteWorkspacesListDeleted(ctx context.Context) ([]siteapi.SiteDeletedWorkspaceResource, error)

SiteWorkspacesListDeleted lists the caller's Owner Workspaces in their deletion window.

func (*Handlers) SiteWorkspacesRestore

SiteWorkspacesRestore restores a Workspace in its deletion window (Owner only).

func (*Handlers) SiteWorkspacesSetSecondFactorRequirement

SiteWorkspacesSetSecondFactorRequirement switches the Workspace's Two-factor requirement on or off; owner and admin only. Turning it off is the one operation a User withheld by the requirement may still perform in the Workspace, so an Owner or Admin without a Second factor is never locked out of lifting it.

func (*Handlers) SiteWorkspacesSetTimezone

SiteWorkspacesSetTimezone sets the Workspace time zone (Owner only, ADR 0057).

func (*Handlers) SiteWorkspacesUpdate

SiteWorkspacesUpdate renames a workspace (Owner and Admin only). The id never changes.

type SystemMailEnqueuer

type SystemMailEnqueuer interface {
	// EnqueuePasswordReset queues the reset mail. With send false the job is queued
	// all the same but nothing is delivered, so forgot-password costs the same
	// for every address.
	EnqueuePasswordReset(ctx context.Context, email, token string, send bool) error
	EnqueueEmailVerification(ctx context.Context, email, token string, send bool) error
	EnqueueEmailChangeConfirm(ctx context.Context, email, token string, send bool) error
	// EnqueueAddressTakenNotice queues the tokenless notice to the owner of a Taken
	// address (ADR 0031). With send false the job is queued but its mail is dropped.
	EnqueueAddressTakenNotice(ctx context.Context, email string, send bool) error
	// EnqueueIdentityLinkedNotice queues the notice to the owner of an account that a Sign-in
	// provider was linked to silently (ADR 0048); token is its "this was not me" link.
	EnqueueIdentityLinkedNotice(ctx context.Context, email, provider, token string) error
	// EnqueueUserDeletedNotice queues the one mail that tells an address its User was deleted
	// (ADR 0050).
	EnqueueUserDeletedNotice(ctx context.Context, email string) error
	// EnqueueUserDeletionLink queues the one-time link that confirms a passwordless User's
	// deletion (ADR 0050). With send false the job is queued but its mail is dropped.
	EnqueueUserDeletionLink(ctx context.Context, email, token string, send bool) error
	// EnqueueMemberInvite sends the workspace invite email. It is best-effort:
	// the invite also returns a copy-link, so a missing/failed mailer (common on
	// self-hosted with no SMTP) must not fail the invite.
	EnqueueMemberInvite(ctx context.Context, email, inviteURL, workspaceName, inviterName string) error
	// EnqueueSecondFactorRequired emails the Workspace's Users without a Second
	// factor that its Two-factor requirement is now on, with their deadline (ADR 0020).
	EnqueueSecondFactorRequired(ctx context.Context, workspaceID int64) error
	// EnqueuePasskeyNotice queues the notice to the owner of an account that a Passkey was
	// added or removed (ADR 0052), so a change they did not make is noticed.
	EnqueuePasskeyNotice(ctx context.Context, email string, change jobs.PasskeyChange, name string) error
}

SystemMailEnqueuer schedules the self-service account emails (password reset, email verification, email-change confirmation) through the platform system sender. Same jobs enqueue seam (river prod, inline tests). The token is minted by the handler; the job builds the link.

type WelcomeEnqueuer

type WelcomeEnqueuer interface {
	EnqueueWelcome(ctx context.Context, email, name string) error
}

WelcomeEnqueuer schedules the platform welcome email after registration. Same jobs enqueue seam (river prod, inline tests).

Directories

Path Synopsis
Package resources holds goverter-generated mappers from ent entities to site API resources (the ogen *Resource DTOs), plus the custom conversions goverter cannot infer on its own.
Package resources holds goverter-generated mappers from ent entities to site API resources (the ogen *Resource DTOs), plus the custom conversions goverter cannot infer on its own.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL