carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package caps
2
3import (
4 "errors"
5 "os"
6 "path/filepath"
7
8 "github.com/carlosframework/platform/internal/rootparticipation"
9)
10
11func (o Ops) authorizeMutation() error {
12 if _, err := os.Lstat(filepath.Join(rootparticipation.Namespace, "census.json")); !errors.Is(err, os.ErrNotExist) {
13 if err != nil {
14 return err
15 }
16 ledger, required, err := rootparticipation.OpenForUpdate()
17 if ledger.State != nil {
18 defer ledger.State.Close()
19 }
20 if err != nil {
21 return err
22 }
23 if required {
24 return os.ErrPermission
25 }
26 }
27 if o.Authorize != nil {
28 return o.Authorize()
29 }
30 return nil
31}
32