Signed-off-by: Cole Speelman <crspeelman@gmail.com>
This commit is contained in:
@@ -25,6 +25,37 @@ type OwnedOrganizationRepository interface {
|
||||
CreateOwnedOrganization(context.Context, OwnedOrganization) error
|
||||
}
|
||||
|
||||
var ErrOwnedManagementUnsupported = errors.New("organizations: atomic owner-managed updates are unsupported")
|
||||
|
||||
// OwnerManagedRepository rechecks the configured direct owner in the same
|
||||
// transaction as profile and membership writes. These explicit operations do
|
||||
// not change legacy methods used by applications with delegated administrators.
|
||||
// Implementations must also preserve optimistic state, last-owner protection,
|
||||
// and audit atomicity. There is no preflight-only fallback.
|
||||
type OwnerManagedRepository interface {
|
||||
UpdateOwnedOrganization(context.Context, Organization, int64, string, AuditEvent) error
|
||||
ChangeOwnedMembershipStatus(context.Context, MembershipStatusChange, string, AuditEvent) error
|
||||
RemoveOwnedMembershipIfCurrent(context.Context, MembershipRemoval, string, AuditEvent) error
|
||||
}
|
||||
|
||||
// UpdateOwnedOrganization changes a non-personal organization's name and slug.
|
||||
// OwnerRole comes from trusted service configuration, not submitted form data.
|
||||
func (service *Service) UpdateOwnedOrganization(ctx context.Context, input UpdateOrganization) (Organization, error) {
|
||||
return service.updateOrganization(ctx, input, true)
|
||||
}
|
||||
|
||||
// ChangeOwnedMembershipStatus requires a current owner even when the target
|
||||
// member is not an owner. It preserves the last active owner.
|
||||
func (service *Service) ChangeOwnedMembershipStatus(ctx context.Context, input MembershipStatusChange) error {
|
||||
return service.changeMembershipStatus(ctx, input, true)
|
||||
}
|
||||
|
||||
// RemoveOwnedMembershipIfCurrent removes only the displayed membership state,
|
||||
// with current owner authority checked in the write transaction.
|
||||
func (service *Service) RemoveOwnedMembershipIfCurrent(ctx context.Context, input MembershipRemoval) error {
|
||||
return service.removeMembershipIfCurrent(ctx, input, true)
|
||||
}
|
||||
|
||||
// CreateOwnedOrganization grants the configured OwnerRole to the initial owner
|
||||
// inside the creation transaction. Applications authorize creation and choose
|
||||
// OwnerRole when constructing the service, never from a submitted role name.
|
||||
|
||||
Reference in New Issue
Block a user