mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Rendering: Fix user information when using render key (#50879)
* Rendering: Fix user information when using render key * fix when render user ID is 0 * update fix * improve fix * add comment
This commit is contained in:
parent
5cbb7003c0
commit
ca80865bf1
@ -449,7 +449,7 @@ func (h *ContextHandler) initContextWithRenderAuth(reqContext *models.ReqContext
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
_, span := h.tracer.Start(reqContext.Req.Context(), "initContextWithRenderAuth")
|
ctx, span := h.tracer.Start(reqContext.Req.Context(), "initContextWithRenderAuth")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
renderUser, exists := h.RenderService.GetRenderUser(reqContext.Req.Context(), key)
|
renderUser, exists := h.RenderService.GetRenderUser(reqContext.Req.Context(), key)
|
||||||
@ -458,12 +458,21 @@ func (h *ContextHandler) initContextWithRenderAuth(reqContext *models.ReqContext
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
reqContext.IsSignedIn = true
|
|
||||||
reqContext.SignedInUser = &models.SignedInUser{
|
reqContext.SignedInUser = &models.SignedInUser{
|
||||||
OrgId: renderUser.OrgID,
|
OrgId: renderUser.OrgID,
|
||||||
UserId: renderUser.UserID,
|
UserId: renderUser.UserID,
|
||||||
OrgRole: models.RoleType(renderUser.OrgRole),
|
OrgRole: models.RoleType(renderUser.OrgRole),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserID can be 0 for background tasks and, in this case, there is no user info to retrieve
|
||||||
|
if renderUser.UserID != 0 {
|
||||||
|
query := models.GetSignedInUserQuery{UserId: renderUser.UserID, OrgId: renderUser.OrgID}
|
||||||
|
if err := h.SQLStore.GetSignedInUserWithCacheCtx(ctx, &query); err == nil {
|
||||||
|
reqContext.SignedInUser = query.Result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reqContext.IsSignedIn = true
|
||||||
reqContext.IsRenderCall = true
|
reqContext.IsRenderCall = true
|
||||||
reqContext.LastSeenAt = time.Now()
|
reqContext.LastSeenAt = time.Now()
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user