* Rendering: Fix user information when using render key
* fix when render user ID is 0
* update fix
* improve fix
* add comment
(cherry picked from commit ca80865bf1)
Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
This commit is contained in:
co-authored by
Agnès Toulet
parent
f3ddc42358
commit
2a25dc7ab8
@@ -445,7 +445,7 @@ func (h *ContextHandler) initContextWithRenderAuth(reqContext *models.ReqContext
|
||||
return false
|
||||
}
|
||||
|
||||
_, span := h.tracer.Start(reqContext.Req.Context(), "initContextWithRenderAuth")
|
||||
ctx, span := h.tracer.Start(reqContext.Req.Context(), "initContextWithRenderAuth")
|
||||
defer span.End()
|
||||
|
||||
renderUser, exists := h.RenderService.GetRenderUser(reqContext.Req.Context(), key)
|
||||
@@ -454,12 +454,21 @@ func (h *ContextHandler) initContextWithRenderAuth(reqContext *models.ReqContext
|
||||
return true
|
||||
}
|
||||
|
||||
reqContext.IsSignedIn = true
|
||||
reqContext.SignedInUser = &models.SignedInUser{
|
||||
OrgId: renderUser.OrgID,
|
||||
UserId: renderUser.UserID,
|
||||
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.LastSeenAt = time.Now()
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user