|
@@ -22,39 +22,39 @@ func (this *BaseAuthController) Prepare() {
|
|
|
fmt.Println("Url:", uri)
|
|
|
if method != "HEAD" {
|
|
|
//校验签名
|
|
|
- //nonce := this.Ctx.Input.Header("nonce")
|
|
|
- //timestamp := this.Ctx.Input.Header("timestamp")
|
|
|
- //appid := this.Ctx.Input.Header("appid")
|
|
|
- //signature := this.Ctx.Input.Header("signature")
|
|
|
- //
|
|
|
- //if nonce == "" {
|
|
|
- // errMsg := "随机字符串不能为空"
|
|
|
- // this.JSON(models.BaseResponse{Ret: 400, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
- // this.StopRun()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //if timestamp == "" {
|
|
|
- // errMsg := "时间戳不能为空"
|
|
|
- // this.JSON(models.BaseResponse{Ret: 400, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
- // this.StopRun()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //if appid != utils.AppId {
|
|
|
- // errMsg := "商家AppId错误,请核查"
|
|
|
- // this.JSON(models.BaseResponse{Ret: 400, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
- // this.StopRun()
|
|
|
- // return
|
|
|
- //}
|
|
|
- //
|
|
|
- //checkSign := utils.GetSign(nonce, timestamp)
|
|
|
- //if signature != checkSign {
|
|
|
- // errMsg := "签名错误"
|
|
|
- // this.JSON(models.BaseResponse{Ret: 401, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
- // this.StopRun()
|
|
|
- // return
|
|
|
- //}
|
|
|
+ nonce := this.Ctx.Input.Header("nonce")
|
|
|
+ timestamp := this.Ctx.Input.Header("timestamp")
|
|
|
+ appid := this.Ctx.Input.Header("appid")
|
|
|
+ signature := this.Ctx.Input.Header("signature")
|
|
|
+
|
|
|
+ if nonce == "" {
|
|
|
+ errMsg := "随机字符串不能为空"
|
|
|
+ this.JSON(models.BaseResponse{Ret: 400, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
+ this.StopRun()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if timestamp == "" {
|
|
|
+ errMsg := "时间戳不能为空"
|
|
|
+ this.JSON(models.BaseResponse{Ret: 400, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
+ this.StopRun()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if appid != utils.AppId {
|
|
|
+ errMsg := "商家AppId错误,请核查"
|
|
|
+ this.JSON(models.BaseResponse{Ret: 400, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
+ this.StopRun()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ checkSign := utils.GetSign(nonce, timestamp)
|
|
|
+ if signature != checkSign {
|
|
|
+ errMsg := "签名错误"
|
|
|
+ this.JSON(models.BaseResponse{Ret: 401, Msg: "", ErrMsg: errMsg}, false, false)
|
|
|
+ this.StopRun()
|
|
|
+ return
|
|
|
+ }
|
|
|
if method != "GET" && method != "POST" {
|
|
|
errMsg := "无效的请求方式"
|
|
|
this.JSON(models.BaseResponse{Ret: 501, Msg: "", ErrMsg: errMsg}, false, false)
|