diff --git a/controller/user.go b/controller/user.go index ff2801d2..3e5293be 100644 --- a/controller/user.go +++ b/controller/user.go @@ -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) + // 不向用户暴露兑换失败的细分原因,避免攻击者根据错误类型判断兑换码状态。 + common.ApiErrorI18n(c, i18n.MsgRedeemFailed) + 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{