OAuth: Enforce auto_assign_org_id setting when role mapping enabled using Generic OAuth (#22268)

* OAuth: Make use of auto_assign_org_id setting
This commit is contained in:
Arve Knudsen authored and GitHub committed 2020-02-19 17:38:53 +01:00
1 parent 4c282c538a
commit 8d1bef3769
2 files changed
+17 -16

No files matched your search

+7 -1
View File
@@ -186,7 +186,13 @@ func (hs *HTTPServer) OAuthLogin(ctx *m.ReqContext) {
if userInfo.Role != "" {
rt := m.RoleType(userInfo.Role)
if rt.IsValid() {
extUser.OrgRoles[1] = rt
var orgID int64
if setting.AutoAssignOrg && setting.AutoAssignOrgId > 0 {
orgID = int64(setting.AutoAssignOrgId)
} else {
orgID = int64(1)
}
extUser.OrgRoles[orgID] = rt
}
}