Version: 0.2.3.dev.260211

fix: 🐛 修复刷新 Token 接口错误返回问题

- 当 token 本身存在问题时,改为返回 400 业务错误
- 不再错误地返回 500 服务端异常状态码 

feat: 🔁 新增基于 X-Idempotency-Key 与 Redis 的通用幂等中间件

- 基于 X-Idempotency-Key 实现请求幂等控制 🧩
- 记录 UUID 及对应返回结果至 Redis
- 当相同 UUID 重复请求时,直接返回缓存结果 
- 应用于所有涉及增删改操作的接口
- 解决部分接口未实现幂等性的问题 🔒
This commit is contained in:
LoveLosita
2026-02-11 16:16:07 +08:00
parent 0bc06963ee
commit cf9a3c79e4
5 changed files with 149 additions and 19 deletions

View File

@@ -91,8 +91,12 @@ func ValidateRefreshToken(tokenString string, cache *dao.CacheDAO) (*jwt.Token,
return RefreshKey, nil
})
if err != nil || !token.Valid {
return nil, err
if err != nil {
return nil, respond.InvalidRefreshToken
}
if !token.Valid {
return nil, respond.InvalidRefreshToken
}
// 2. 断言获取 Claims