mirror of
https://github.com/optim-enterprises-bv/databunker.git
synced 2025-11-02 02:48:05 +00:00
validate for broken json input
This commit is contained in:
@@ -31,7 +31,7 @@ func (e mainEnv) userappNew(w http.ResponseWriter, r *http.Request, ps httproute
|
||||
|
||||
data, err := getJSONPostData(r)
|
||||
if err != nil {
|
||||
returnError(w, r, "internal error", 405, err, event)
|
||||
returnError(w, r, "failed to decode request body", 405, err, event)
|
||||
return
|
||||
}
|
||||
jsonData, err := json.Marshal(data)
|
||||
@@ -67,7 +67,7 @@ func (e mainEnv) userappChange(w http.ResponseWriter, r *http.Request, ps httpro
|
||||
|
||||
data, err := getJSONPostData(r)
|
||||
if err != nil {
|
||||
returnError(w, r, "internal error", 405, err, event)
|
||||
returnError(w, r, "failed to decode request body", 405, err, event)
|
||||
return
|
||||
}
|
||||
jsonData, err := json.Marshal(data)
|
||||
|
||||
@@ -20,7 +20,7 @@ func (e mainEnv) userNew(w http.ResponseWriter, r *http.Request, ps httprouter.P
|
||||
}
|
||||
parsedData, err := getJSONPost(r, e.conf.Sms.Default_country)
|
||||
if err != nil {
|
||||
returnError(w, r, "internal error", 405, err, event)
|
||||
returnError(w, r, "failed to decode request body", 405, err, event)
|
||||
return
|
||||
}
|
||||
// make sure that login, email and phone are unique
|
||||
@@ -125,7 +125,7 @@ func (e mainEnv) userChange(w http.ResponseWriter, r *http.Request, ps httproute
|
||||
}
|
||||
parsedData, err := getJSONPost(r, e.conf.Sms.Default_country)
|
||||
if err != nil {
|
||||
returnError(w, r, "internal error", 405, err, event)
|
||||
returnError(w, r, "failed to decode request body", 405, err, event)
|
||||
return
|
||||
}
|
||||
userTOKEN := address
|
||||
|
||||
@@ -272,8 +272,11 @@ func getJSONPostData(r *http.Request) (map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
func getJSONPost(r *http.Request, default_country string) (userJSON, error) {
|
||||
records, err := getJSONPostData(r)
|
||||
var result userJSON
|
||||
records, err := getJSONPostData(r)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
if value, ok := records["login"]; ok {
|
||||
if reflect.TypeOf(value) == reflect.TypeOf("string") {
|
||||
|
||||
@@ -24,7 +24,7 @@ func (e mainEnv) userNewToken(w http.ResponseWriter, r *http.Request, ps httprou
|
||||
}
|
||||
records, err := getJSONPostData(r)
|
||||
if err != nil {
|
||||
returnError(w, r, "internal error", 405, err, event)
|
||||
returnError(w, r, "failed to decode request body", 405, err, event)
|
||||
return
|
||||
}
|
||||
fields := ""
|
||||
|
||||
Reference in New Issue
Block a user