package calls // Home sign-in for a roster member with no account here: connect's three // team-mode hooks (Admit, HomeOnly, Unlinked) over Calls' persons table. // connect completes an // ordinary Home sign-in only for a subject with an account link, and // refuses the rest as "unknown" — right for an allowlist instance, where // nobody may enter on a Home identity alone. In team mode a roster member // who has never had a local account must be able to, so wireHome gives // connect these, and connect's own completion does the rest (its cookie // checks, the same-person rule, the link flow, and since connect's member // choice the choose page: connect an existing email account, or "I'm new // here", which makes the Home-only person). // // The person Unlinked creates is identity, never standing: every request // after this one asks the roster again (team_access.go). // // A Home-only person has NO address, here or in Home. Their persons row's // email column holds a random "home-only:" placeholder, because the // column is NOT NULL and UNIQUE and migrations are additive-only; nothing // mails it or shows it (Person.shown), and their name — what a call's // roster shows the others — is "Oficina account …xxxx". Calls mails // nobody but a person signing in by link, so the only thing this costs // them is local sign-in: they sign in through Oficina. import ( "context" "database/sql" "errors" "amadan.net/oficina/home/connect" "amadan.net/oficina/home/teammode" "amadan.net/oficina/calls/internal/calls/teamstate" ) // teamAdmit is connect's Admit, the roster decision taken first (Home spec // 2026-11-14-oficina-id-native.md §8) for a subject with neither a link // nor a Home-only person: Runtime.AdmitUnlinked, which allocates nothing // and never asks whether Calls has local accounts. A Member is asked to // choose (connect's choose page: connect an existing email account, or // "I'm new here", which then reaches teamUnlinked); a stranger is // connect's "unknown"; an undecidable roster is a 503. func (a *app) teamAdmit(ctx context.Context, issuer, subject string) error { if a.team == nil { return errTeamUnavailable } switch err := a.team.AdmitUnlinked(ctx, issuer, subject); { case err == nil: return nil case errors.Is(err, teammode.ErrNotMember): return connect.ErrNoPerson } return errTeamUnavailable } // teamHomeOnly is connect's HomeOnly: the addressless person Unlinked // gave a subject, read and never created. func (a *app) teamHomeOnly(d *sql.DB) func(context.Context, string, string) (connect.Person, error) { return func(ctx context.Context, issuer, subject string) (connect.Person, error) { id, err := teamstate.HomePerson(ctx, d, issuer, subject) switch { case err == nil: return connect.Person{ID: id}, nil case errors.Is(err, teamstate.ErrRefused): return connect.Person{}, connect.ErrNoPerson } return connect.Person{}, errTeamUnavailable } } // teamUnlinked is connect's Unlinked, asked only after a Member chose "I'm // new here" with nobody signed in, for a subject with neither a link nor // a Home-only person (connect rechecks teamAdmit first): an // addressless person for a subject the roster says is a Member now, with // the lease on that answer still valid (Runtime.AdmitUnlinked). A // stranger is connect's "unknown"; an undecidable roster is a 503. func (a *app) teamUnlinked(d *sql.DB) func(context.Context, string, string) (connect.Person, error) { return func(ctx context.Context, issuer, subject string) (connect.Person, error) { if a.team == nil { return connect.Person{}, errTeamUnavailable } if err := a.team.AdmitUnlinked(ctx, issuer, subject); err != nil { if errors.Is(err, teammode.ErrNotMember) { return connect.Person{}, connect.ErrNoPerson } return connect.Person{}, errTeamUnavailable } id, _, err := teamstate.EnsureHomePerson(ctx, d, issuer, subject, homeOnlyLabel(subject)) switch { case err == nil: return connect.Person{ID: id}, nil case errors.Is(err, teamstate.ErrRefused): // Linked to a local account in the meantime: that person // signs in as that account, not as a new one. return connect.Person{}, connect.ErrNoPerson } return connect.Person{}, errTeamUnavailable } }