User: Expose GCOM user ID as externalUserId in grafanaBootData (#47307)

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* fix sql indtent

Co-authored-by: Joao Silva <joao.silva@grafana.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
This commit is contained in:
Josh Hunt
2022-04-05 14:44:33 +01:00
committed by GitHub
co-authored by Joao Silva Ashley Harrison
parent 05098ec38e
commit 71db5115f4
4 changed files with 35 additions and 24 deletions
+17 -10
View File
@@ -540,18 +540,21 @@ func (ss *SQLStore) GetSignedInUser(ctx context.Context, query *models.GetSigned
}
var rawSQL = `SELECT
u.id as user_id,
u.is_admin as is_grafana_admin,
u.email as email,
u.login as login,
u.name as name,
u.help_flags1 as help_flags1,
u.last_seen_at as last_seen_at,
u.id as user_id,
u.is_admin as is_grafana_admin,
u.email as email,
u.login as login,
u.name as name,
u.help_flags1 as help_flags1,
u.last_seen_at as last_seen_at,
(SELECT COUNT(*) FROM org_user where org_user.user_id = u.id) as org_count,
org.name as org_name,
org_user.role as org_role,
org.id as org_id
user_auth.auth_module as external_auth_module,
user_auth.auth_id as external_auth_id,
org.name as org_name,
org_user.role as org_role,
org.id as org_id
FROM ` + dialect.Quote("user") + ` as u
LEFT OUTER JOIN user_auth on user_auth.user_id = u.id
LEFT OUTER JOIN org_user on org_user.org_id = ` + orgId + ` and org_user.user_id = u.id
LEFT OUTER JOIN org on org.id = org_user.org_id `
@@ -579,6 +582,10 @@ func (ss *SQLStore) GetSignedInUser(ctx context.Context, query *models.GetSigned
user.OrgName = "Org missing"
}
if user.ExternalAuthModule != "oauth_grafana_com" {
user.ExternalAuthId = ""
}
getTeamsByUserQuery := &models.GetTeamsByUserQuery{OrgId: user.OrgId, UserId: user.UserId}
err = ss.GetTeamsByUser(ctx, getTeamsByUserQuery)
if err != nil {