dengbiao 2 days ago
parent
commit
bb0170dfb9
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      app/lib/aes/check.go

+ 14
- 2
app/lib/aes/check.go View File

@@ -77,8 +77,20 @@ func CheckSign(c *gin.Context) error {
if err != nil {
return err
}
if currentTimestamp-storedTimestamp > 300 { // 5分钟
return fmt.Errorf("签名过期!")
if currentTimestamp-storedTimestamp < 0 {
//TODO::兼容客户端传毫秒
currentTimestamp = time.Now().UnixMilli()
if currentTimestamp-storedTimestamp > 60*2*1000 { // 2分钟
return fmt.Errorf("签名过期!")
}
} else {
if currentTimestamp-storedTimestamp > 60*2 { // 2分钟
return fmt.Errorf("签名过期!")
}
}

if currentTimestamp-storedTimestamp < 0 {
return errors.New("签名有误!")
}
return nil
}

Loading…
Cancel
Save