Commit 59530e47 by Leonard Gram Committed by GitHub

Quota: Makes sure we provide the request context to the quota service (#21949)

It was missing for ldap_login which means that the first signup failed
for users with LDAP+quota enabled. There's also potential cases where we
can't provide a request context (background jobs) which is also covered,
but needs a refactoring.
parent c16040a4
...@@ -216,6 +216,7 @@ func (server *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) Response { ...@@ -216,6 +216,7 @@ func (server *HTTPServer) PostSyncUserWithLDAP(c *models.ReqContext) Response {
} }
upsertCmd := &models.UpsertUserCommand{ upsertCmd := &models.UpsertUserCommand{
ReqContext: c,
ExternalUser: user, ExternalUser: user,
SignupAllowed: setting.LDAPAllowSignup, SignupAllowed: setting.LDAPAllowSignup,
} }
......
...@@ -51,6 +51,7 @@ var loginUsingLDAP = func(query *models.LoginUserQuery) (bool, error) { ...@@ -51,6 +51,7 @@ var loginUsingLDAP = func(query *models.LoginUserQuery) (bool, error) {
} }
upsert := &models.UpsertUserCommand{ upsert := &models.UpsertUserCommand{
ReqContext: query.ReqContext,
ExternalUser: externalUser, ExternalUser: externalUser,
SignupAllowed: setting.LDAPAllowSignup, SignupAllowed: setting.LDAPAllowSignup,
} }
......
...@@ -23,7 +23,12 @@ func (qs *QuotaService) QuotaReached(c *m.ReqContext, target string) (bool, erro ...@@ -23,7 +23,12 @@ func (qs *QuotaService) QuotaReached(c *m.ReqContext, target string) (bool, erro
if !setting.Quota.Enabled { if !setting.Quota.Enabled {
return false, nil return false, nil
} }
// No request context means this is a background service, like LDAP Background Sync.
// TODO: we should replace the req context with a more limited interface or struct,
// something that we could easily provide from background jobs.
if c == nil {
return false, nil
}
// get the list of scopes that this target is valid for. Org, User, Global // get the list of scopes that this target is valid for. Org, User, Global
scopes, err := m.GetQuotaScopes(target) scopes, err := m.GetQuotaScopes(target)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment