Chore: Add Get User Profile to user and Get User Org List to org service (#53788)

* Remove delete suer from store interface

* Remove get signed in user with cache ctx from store interface

* Support options when setting up access control tests

* Fix broken tests

* Fix lint

* Add user fake to middleware

* Fix middleware tests, remove usertest being initialised twice

* Chore: Add Get User Profile to user and Get User Org List to org service

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
This commit is contained in:
idafurjes
2022-08-16 17:50:45 +02:00
committed by GitHub
co-authored by Karl Persson
parent d1df896962
commit e3501dfa4d
8 changed files with 97 additions and 2 deletions
+28
View File
@@ -410,3 +410,31 @@ func (s *Service) SetUserHelpFlag(ctx context.Context, cmd *user.SetUserHelpFlag
}
return s.sqlStore.SetUserHelpFlag(ctx, c)
}
// TODO: remove wrapper around sqlstore
func (s *Service) GetUserProfile(ctx context.Context, query *user.GetUserProfileQuery) (user.UserProfileDTO, error) {
q := &models.GetUserProfileQuery{
UserId: query.UserID,
}
err := s.sqlStore.GetUserProfile(ctx, q)
if err != nil {
return user.UserProfileDTO{}, err
}
result := user.UserProfileDTO{
ID: q.Result.Id,
Email: q.Result.Email,
Name: q.Result.Name,
Login: q.Result.Login,
Theme: q.Result.Theme,
OrgID: q.Result.OrgId,
IsGrafanaAdmin: q.Result.IsGrafanaAdmin,
IsDisabled: q.Result.IsDisabled,
IsExternal: q.Result.IsExternal,
AuthLabels: q.Result.AuthLabels,
UpdatedAt: q.Result.UpdatedAt,
CreatedAt: q.Result.CreatedAt,
AvatarUrl: q.Result.AvatarUrl,
AccessControl: q.Result.AccessControl,
}
return result, nil
}