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 | 1 | package controllers |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | + "apigame/middleware/sign" | |
| 4 | 5 | "apigame/models" |
| 5 | 6 | "apigame/service/cardholder" |
| 7 | + code_msg "apigame/service/code-msg" | |
| 6 | 8 | ) |
| 7 | 9 | |
| 8 | 10 | // CardHolderController 绑定控制器 |
| ... | ... | @@ -12,12 +14,20 @@ type CardHolderController struct { |
| 12 | 14 | |
| 13 | 15 | // GetConfig 活动配置 |
| 14 | 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 | 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 | 32 | c.RetRspCodeData(code, rsp) |
| 23 | 33 | } | ... | ... |
middleware/sign/index.go
| ... | ... | @@ -12,8 +12,6 @@ import ( |
| 12 | 12 | "encoding/json" |
| 13 | 13 | "errors" |
| 14 | 14 | "fmt" |
| 15 | - "reflect" | |
| 16 | - | |
| 17 | 15 | "sort" |
| 18 | 16 | "strings" |
| 19 | 17 | "unicode/utf8" |
| ... | ... | @@ -171,10 +169,6 @@ func Check(req []byte, postdata interface{}, checkSign bool, checkToken bool) (c |
| 171 | 169 | |
| 172 | 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 | 172 | b, err = valid.Valid(postdata) |
| 179 | 173 | if err != nil { |
| 180 | 174 | code = code_msg.RECODE_PARAMERROR | ... | ... |