REST cli: allow to disable password or public_key auth

using something like this:

update-user <user-id> <username> --public-keys ''

the public keys auth will be disabled

using something like this:

update-user <user-id> <username> --password ''

the password auth will be disabled
This commit is contained in:
Nicola Murino
2019-12-29 14:07:44 +01:00
parent 6aff8c2f5e
commit 741e65a3a1
2 changed files with 8 additions and 5 deletions

View File

@@ -74,6 +74,7 @@ func getUserByID(w http.ResponseWriter, r *http.Request) {
func addUser(w http.ResponseWriter, r *http.Request) {
var user dataprovider.User
user.PublicKeys = []string{}
err := render.DecodeJSON(r.Body, &user)
if err != nil {
sendAPIResponse(w, r, err, "", http.StatusBadRequest)
@@ -84,7 +85,6 @@ func addUser(w http.ResponseWriter, r *http.Request) {
user, err = dataprovider.UserExists(dataProvider, user.Username)
if err == nil {
user.Password = ""
user.PublicKeys = []string{}
render.JSON(w, r, user)
} else {
sendAPIResponse(w, r, err, "", http.StatusInternalServerError)