feat(user): better messages for redeem failures
This commit is contained in:
+2
-4
@@ -1311,11 +1311,9 @@ func TopUp(c *gin.Context) {
|
||||
}
|
||||
quota, err := model.Redeem(req.Key, id)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrRedeemFailed) {
|
||||
// 不向用户暴露兑换失败的细分原因,避免攻击者根据错误类型判断兑换码状态。
|
||||
common.ApiErrorI18n(c, i18n.MsgRedeemFailed)
|
||||
return
|
||||
}
|
||||
common.ApiError(c, err)
|
||||
logger.LogError(c, fmt.Sprintf("failed to redeem key %s for user %d: %s", req.Key, id, err.Error()))
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
|
||||
Reference in New Issue
Block a user