package caps import ( "errors" "os" "path/filepath" "github.com/carlosframework/platform/internal/rootparticipation" ) func (o Ops) authorizeMutation() error { if _, err := os.Lstat(filepath.Join(rootparticipation.Namespace, "census.json")); !errors.Is(err, os.ErrNotExist) { if err != nil { return err } ledger, required, err := rootparticipation.OpenForUpdate() if ledger.State != nil { defer ledger.State.Close() } if err != nil { return err } if required { return os.ErrPermission } } if o.Authorize != nil { return o.Authorize() } return nil }