This commit is contained in:
@@ -19,6 +19,42 @@ ordinary invitations but cannot create or cancel owner access.
|
||||
Applications own invitation pages, email or out-of-band delivery, active-source
|
||||
checks before archival, and account recovery.
|
||||
|
||||
## Creating an organization with an owner
|
||||
|
||||
For an existing authenticated user creating a business, use
|
||||
`CreateOwnedOrganization` with `OwnerRole` configured when constructing the
|
||||
service. Seed that role first. This commits the organization, active membership,
|
||||
direct organization-wide owner binding, and both creation/access audit events in
|
||||
one transaction. `CreateOrganization.RequestID` correlates those audit events.
|
||||
The owner must be an active user whose registration has completed.
|
||||
|
||||
The application authorizes creation and chooses the role; do not accept an owner
|
||||
role name from a browser or API payload. A customer-owner role can intentionally
|
||||
have different permissions from an installation's merchant-owner role. Creating
|
||||
a customer organization grants no authority in any other organization.
|
||||
|
||||
```go
|
||||
customers, err := organizations.New(store, organizations.Options{
|
||||
OwnerRole: "customer.owner", // Application-defined, already seeded.
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
business, err := customers.CreateOwnedOrganization(ctx, organizations.CreateOrganization{
|
||||
Slug: "example-business", Name: "Example Business", OwnerUserID: principal.User.ID,
|
||||
RequestID: requestID,
|
||||
})
|
||||
```
|
||||
|
||||
Repositories implement `OwnedOrganizationRepository` to support this operation.
|
||||
There is no create-then-grant fallback: unsupported adapters return
|
||||
`ErrOwnedCreationUnsupported`. The older `CreateOrganization` and
|
||||
`CreatePersonalOrganization` retain their membership-only behavior; configuring
|
||||
`OwnerRole` does not silently change them. The separate `account` package still
|
||||
owns atomic public signup, including personal organization and credentials.
|
||||
|
||||
## Membership and access lifecycle
|
||||
|
||||
Organizations and teams use optimistic revisions and reversible
|
||||
`active`/`archived` states. Archived objects keep their history but contribute
|
||||
no effective authority. Memberships may be suspended, reactivated, or removed;
|
||||
|
||||
Reference in New Issue
Block a user