summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-10-06 11:32:23 +0900
committerRandomChars <random@chars.jp>2021-10-06 11:32:23 +0900
commit1a987c9e04109505681b4ae0d6b7700d8b3b6f13 (patch)
tree2ee83719244cc4e6ef97be817f0700b07d6d14a9
parent5c0d5069c3e8f3ce2ca3c038bedff8121abce936 (diff)
set user privileged through APIv1.3.10
-rw-r--r--api.go3
-rw-r--r--api/types.go3
-rw-r--r--client/user.go4
3 files changed, 7 insertions, 3 deletions
diff --git a/api.go b/api.go
index 05d4d74..178c3f0 100644
--- a/api.go
+++ b/api.go
@@ -118,6 +118,9 @@ func registerAPI() {
return
}
+ if info.Privileged {
+ instance.UserPrivileged(flake, payload.Privileged)
+ }
instance.UserUsernameUpdate(flake, payload.Username)
})
diff --git a/api/types.go b/api/types.go
index 5c58f06..a86cfb7 100644
--- a/api/types.go
+++ b/api/types.go
@@ -13,7 +13,8 @@ type UserCreatePayload struct {
}
type UserUpdatePayload struct {
- Username string `json:"username"`
+ Username string `json:"username"`
+ Privileged bool `json:"privileged,omitempty"`
}
type UserSecretPayload struct {
diff --git a/client/user.go b/client/user.go
index 97985e6..53c8829 100644
--- a/client/user.go
+++ b/client/user.go
@@ -52,10 +52,10 @@ func (r *Remote) UserAdd(username string, password string, privileged bool) (sto
}
// UserUpdate updates a user.
-func (r *Remote) UserUpdate(flake, newname string) error {
+func (r *Remote) UserUpdate(flake, newname string, privileged bool) error {
return r.requestJSONnoResp(http.MethodPatch,
populateField(api.UserField, "flake", flake),
- api.UserUpdatePayload{Username: newname})
+ api.UserUpdatePayload{Username: newname, Privileged: privileged})
}
// UserDestroy destroys a user.