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

This commit is contained in:
CaIon
2024-01-11 14:58:17 +08:00
parent d062bc60e4
commit 98a8c5ca2d
2 changed files with 21 additions and 4 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])