Point message validation

This commit is contained in:
Denis Zheleztsov 2018-11-06 12:38:38 +03:00
parent 53163e6f8d
commit 612fc8ac07
2 changed files with 8 additions and 2 deletions

View File

@ -83,7 +83,7 @@ func (es ESConf) UMHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
e := vars["ids"] e := vars["ids"]
log.Print("/u/e/ vars: ", e) log.Print("/u/m/ vars: ", e)
LogRequest(r) LogRequest(r)
@ -155,6 +155,9 @@ func (es ESConf) UPointHandler(w http.ResponseWriter, r *http.Request) {
// Get plain POST variables // Get plain POST variables
if err := r.ParseForm(); err != nil { if err := r.ParseForm(); err != nil {
log.Error("Fail to parse POST args: ", err.Error()) log.Error("Fail to parse POST args: ", err.Error())
w.WriteHeader(500)
w.Write([]byte(fmt.Sprintf("error: %s", err.Error())))
return
} }
pauth := r.Form.Get("pauth") pauth := r.Form.Get("pauth")
tmsg := r.Form.Get("tmsg") tmsg := r.Form.Get("tmsg")
@ -183,7 +186,7 @@ func (es ESConf) UPointHandler(w http.ResponseWriter, r *http.Request) {
// Proccess point message // Proccess point message
if err := es.PointMessage(req, user); err != nil { if err := es.PointMessage(req, user); err != nil {
log.Error(err.Error()) log.Error("Fail to parse point message: ", err.Error())
w.WriteHeader(500) w.WriteHeader(500)
w.Write([]byte(fmt.Sprintf("error: %s", err.Error()))) w.Write([]byte(fmt.Sprintf("error: %s", err.Error())))
return return

View File

@ -31,6 +31,9 @@ func (es ESConf) PointMessage(req PointRequest, user User) error {
if err != nil { if err != nil {
return err return err
} }
if err := pmsg.Validate(); err != nil {
return err
}
bmsg, err := idec.MakeBundledMessage(pmsg) bmsg, err := idec.MakeBundledMessage(pmsg)
if err != nil { if err != nil {