Commit 5c674f005758db6e750b1f4968e670f6078729ea
1 parent
8b050323
Exists in
master
and in
1 other branch
test✅:调试签名验证日志
Showing
2 changed files
with
13 additions
and
9 deletions
Show diff stats
controllers/cardholder.go
| 1 | package controllers | 1 | package controllers |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "apigame/middleware/sign" | ||
| 4 | "apigame/models" | 5 | "apigame/models" |
| 5 | "apigame/service/cardholder" | 6 | "apigame/service/cardholder" |
| 7 | + code_msg "apigame/service/code-msg" | ||
| 6 | ) | 8 | ) |
| 7 | 9 | ||
| 8 | // CardHolderController 绑定控制器 | 10 | // CardHolderController 绑定控制器 |
| @@ -12,12 +14,20 @@ type CardHolderController struct { | @@ -12,12 +14,20 @@ type CardHolderController struct { | ||
| 12 | 14 | ||
| 13 | // GetConfig 活动配置 | 15 | // GetConfig 活动配置 |
| 14 | func (c *CardHolderController) GetConfig() { | 16 | func (c *CardHolderController) GetConfig() { |
| 15 | - req := new(models.ReqCardHolderGetConfig) | ||
| 16 | - if !c.GetPostData(*req) { | 17 | + req := models.ReqCardHolderGetConfig{} |
| 18 | + codeCheck, err := sign.Check(c.Ctx.Input.RequestBody, &req, true, true) | ||
| 19 | + if err != nil { | ||
| 20 | + resp := make(map[string]interface{}) | ||
| 21 | + resp = code_msg.CodeMsg(resp, codeCheck) | ||
| 22 | + c.RetData(resp) | ||
| 17 | return | 23 | return |
| 18 | } | 24 | } |
| 19 | 25 | ||
| 20 | - code, rsp := cardholder.HandleGetConfig(req) | 26 | + //if !c.GetPostData(*req) { |
| 27 | + // return | ||
| 28 | + //} | ||
| 29 | + | ||
| 30 | + code, rsp := cardholder.HandleGetConfig(&req) | ||
| 21 | 31 | ||
| 22 | c.RetRspCodeData(code, rsp) | 32 | c.RetRspCodeData(code, rsp) |
| 23 | } | 33 | } |
middleware/sign/index.go
| @@ -12,8 +12,6 @@ import ( | @@ -12,8 +12,6 @@ import ( | ||
| 12 | "encoding/json" | 12 | "encoding/json" |
| 13 | "errors" | 13 | "errors" |
| 14 | "fmt" | 14 | "fmt" |
| 15 | - "reflect" | ||
| 16 | - | ||
| 17 | "sort" | 15 | "sort" |
| 18 | "strings" | 16 | "strings" |
| 19 | "unicode/utf8" | 17 | "unicode/utf8" |
| @@ -171,10 +169,6 @@ func Check(req []byte, postdata interface{}, checkSign bool, checkToken bool) (c | @@ -171,10 +169,6 @@ func Check(req []byte, postdata interface{}, checkSign bool, checkToken bool) (c | ||
| 171 | 169 | ||
| 172 | var b bool | 170 | var b bool |
| 173 | 171 | ||
| 174 | - lxalilog.Errors(postdata) | ||
| 175 | - lxalilog.Errors(reflect.TypeOf(postdata)) | ||
| 176 | - lxalilog.Errors(reflect.TypeOf(postdata).Kind()) | ||
| 177 | - | ||
| 178 | b, err = valid.Valid(postdata) | 172 | b, err = valid.Valid(postdata) |
| 179 | if err != nil { | 173 | if err != nil { |
| 180 | code = code_msg.RECODE_PARAMERROR | 174 | code = code_msg.RECODE_PARAMERROR |