Accept name in body if matches url

master
Bel LaPointe 2020-07-24 18:55:04 -06:00
parent 51506925bc
commit afba6a71f0
1 changed files with 4 additions and 0 deletions

View File

@ -131,6 +131,10 @@ func whoPost(namespace string, g storage.Graph, w http.ResponseWriter, r *http.R
if err := json.NewDecoder(r.Body).Decode(&one); err != nil { if err := json.NewDecoder(r.Body).Decode(&one); err != nil {
return err return err
} }
if one.Name != "" && one.Name != id {
http.Error(w, `{"error":"names differ between URL and request body"}`, http.StatusBadRequest)
return nil
}
one.Name = id one.Name = id
if err := g.Insert(r.Context(), namespace, one); err != nil { if err := g.Insert(r.Context(), namespace, one); err != nil {
return err return err