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