Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
2 Bug fixes.
Browse files Browse the repository at this point in the history
1. Fix bug introduced in last commit.
Don't try to json encode data that is already encoded.

2. Honor --max-number-client-config
When the creation moved from Clients.svelte to NewClient.svelte the
check in returned json for errors got lost. Now it is back.
  • Loading branch information
spetzreborn committed Apr 8, 2020
1 parent 43dd7bb commit 7d1c38b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
9 changes: 2 additions & 7 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,19 +603,14 @@ func (s *Server) CreateClient(w http.ResponseWriter, r *http.Request, ps httprou
Error: "Max number of configs: " + strconv.Itoa(*maxNumberClientConfig),
}

j, err := json.Marshal(e)
if err != nil {
log.Error(err)
return
}

w.WriteHeader(http.StatusBadRequest)
err = json.NewEncoder(w).Encode(j)
err := json.NewEncoder(w).Encode(e)
if err != nil {
log.Error(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
return
}
}

Expand Down
16 changes: 13 additions & 3 deletions ui/src/NewClient.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@
"Content-Type": "application/json",
},
body: JSON.stringify(client),
})
.then(response => {
return response.json();
})
.then(data => {
if (typeof data.Error != "undefined") {
console.log(data.Error);
alert(data.Error);
} else {
console.log("New client added", data);
}
});
client = await res.json();
console.log("New client added", client);
navigate("/", { replace: true });
}
};
function handleBackClick(event) {
navigate("/", { replace: true });
Expand Down

0 comments on commit 7d1c38b

Please sign in to comment.