Replace signed in user for identity.requester (#73750)
* Make identity.Requester available at Context * Clean pkg/services/guardian/guardian.go * Clean guardian provider and guardian AC * Clean pkg/api/team.go * Clean ctxhandler, datasources, plugin and live * Question: what to do with the UserDisplayDTO? * Clean dashboards and guardian * Remove identity.Requester from ReqContext * Implement NewUserDisplayDTOFromRequester * Fix tests * Change status code numbers for http constants * Upgrade signature of ngalert services * log parsing errors instead of throwing error * Fix tests and add logs * linting
This commit is contained in:
@@ -3,21 +3,21 @@ package livecontext
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||
)
|
||||
|
||||
type signedUserContextKeyType int
|
||||
|
||||
var signedUserContextKey signedUserContextKeyType
|
||||
|
||||
func SetContextSignedUser(ctx context.Context, user *user.SignedInUser) context.Context {
|
||||
func SetContextSignedUser(ctx context.Context, user identity.Requester) context.Context {
|
||||
ctx = context.WithValue(ctx, signedUserContextKey, user)
|
||||
return ctx
|
||||
}
|
||||
|
||||
func GetContextSignedUser(ctx context.Context) (*user.SignedInUser, bool) {
|
||||
func GetContextSignedUser(ctx context.Context) (identity.Requester, bool) {
|
||||
if val := ctx.Value(signedUserContextKey); val != nil {
|
||||
user, ok := val.(*user.SignedInUser)
|
||||
user, ok := val.(identity.Requester)
|
||||
return user, ok
|
||||
}
|
||||
return nil, false
|
||||
|
||||
Reference in New Issue
Block a user