AuthN: User Quota (#61540)

* remove reqContext from quota checks in login

* add guards for nil ScopeParams
This commit is contained in:
Jo
2023-01-16 11:54:15 +01:00
committed by GitHub
parent a4c2237d16
commit dcfeab2c73
8 changed files with 30 additions and 8 deletions
+7 -1
View File
@@ -156,7 +156,13 @@ func (api *API) RegisterAPIEndpoints(m *metrics.API) {
func (api *API) Usage(ctx context.Context, scopeParams *quota.ScopeParameters) (*quota.Map, error) {
u := &quota.Map{}
if orgUsage, err := api.RuleStore.Count(ctx, scopeParams.OrgID); err != nil {
var orgID int64 = 0
if scopeParams != nil {
orgID = scopeParams.OrgID
}
if orgUsage, err := api.RuleStore.Count(ctx, orgID); err != nil {
return u, err
} else {
tag, err := quota.NewTag(models.QuotaTargetSrv, models.QuotaTarget, quota.OrgScope)