cmd/uplink: allow public access registration
Change-Id: I1316f10158d8a466bc80d6548ad0773016bfb916
This commit is contained in:
parent
a8b66dce17
commit
54ae9b040e
@ -4,12 +4,12 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcutil/base58"
|
||||
"github.com/spf13/cobra"
|
||||
@ -23,6 +23,7 @@ import (
|
||||
|
||||
type registerConfig struct {
|
||||
AuthService string `help:"the address to the service you wish to register your access with" default:"" basic-help:"true"`
|
||||
Public bool `help:"if the access should be public" default:"false" basic-help:"true"`
|
||||
AccessConfig
|
||||
}
|
||||
|
||||
@ -165,7 +166,15 @@ func registerAccess(cmd *cobra.Command, args []string) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := http.Post(fmt.Sprintf("%s/v1/access", registerCfg.AuthService), "application/json", strings.NewReader(fmt.Sprintf(`{"access_grant":"%s"}`, accessRaw)))
|
||||
postData, err := json.Marshal(map[string]interface{}{
|
||||
"access_grant": accessRaw,
|
||||
"public": registerCfg.Public,
|
||||
})
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
resp, err := http.Post(fmt.Sprintf("%s/v1/access", registerCfg.AuthService), "application/json", bytes.NewReader(postData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user