From 85fd0fda712eb4a515dcffb763ef3cf1f9e33f7c Mon Sep 17 00:00:00 2001 From: sp Date: Thu, 29 Apr 2021 10:38:10 +1000 Subject: [PATCH] check invalid settlement and ts time --- apiV1PayIn.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apiV1PayIn.go b/apiV1PayIn.go index fac9f61..ce70084 100644 --- a/apiV1PayIn.go +++ b/apiV1PayIn.go @@ -6,6 +6,7 @@ import ( log "github.com/sirupsen/logrus" "net/http" "strconv" + "time" ) func decodeJsonPayInEdit(r *http.Request) (ret loan.PayIn, e error) { @@ -28,6 +29,13 @@ func apiV1PayInPost(w http.ResponseWriter, r *http.Request, ss *loan.Session) { apiV1Client404Error(w, r, ss) return } else { + lowerBound, _ := time.Parse("2006-01-02", "1900-01-01") + if input.Settlement.Before(lowerBound) { + input.Settlement = lowerBound + } + if input.Ts.Before(lowerBound) { + input.Ts = time.Now() + } e = input.Write() if e != nil { log.Error("cannot save basic loan", e.Error())