fix: 修复高并发下,高额度用户使用低额度令牌没有预扣费而导致令牌大额欠费

This commit is contained in:
CaIon
2024-01-11 14:53:55 +08:00
parent a1e3c9a710
commit f0ffe14437
2 changed files with 19 additions and 9 deletions

View File

@@ -106,6 +106,10 @@ func TokenAuth() func(c *gin.Context) {
c.Set("id", token.UserId)
c.Set("token_id", token.Id)
c.Set("token_name", token.Name)
c.Set("token_unlimited_quota", token.UnlimitedQuota)
if !token.UnlimitedQuota {
c.Set("token_quota", token.RemainQuota)
}
if len(parts) > 1 {
if model.IsAdmin(token.UserId) {
c.Set("channelId", parts[1])