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:
co-authored by
Karl Persson
parent
d1df896962
commit
e3501dfa4d
@@ -6,7 +6,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
@@ -16,6 +18,8 @@ type Service struct {
|
||||
store store
|
||||
cfg *setting.Cfg
|
||||
log log.Logger
|
||||
// TODO remove sqlstore
|
||||
sqlStore *sqlstore.SQLStore
|
||||
}
|
||||
|
||||
func ProvideService(db db.DB, cfg *setting.Cfg) org.Service {
|
||||
@@ -80,3 +84,23 @@ func (s *Service) InsertOrgUser(ctx context.Context, orguser *org.OrgUser) (int6
|
||||
func (s *Service) DeleteUserFromAll(ctx context.Context, userID int64) error {
|
||||
return s.store.DeleteUserFromAll(ctx, userID)
|
||||
}
|
||||
|
||||
// TODO: remove wrapper around sqlstore
|
||||
func (s *Service) GetUserOrgList(ctx context.Context, query *org.GetUserOrgListQuery) ([]*org.UserOrgDTO, error) {
|
||||
q := &models.GetUserOrgListQuery{
|
||||
UserId: query.UserID,
|
||||
}
|
||||
err := s.sqlStore.GetUserOrgList(ctx, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []*org.UserOrgDTO
|
||||
for _, orga := range q.Result {
|
||||
result = append(result, &org.UserOrgDTO{
|
||||
OrgID: orga.OrgId,
|
||||
Name: orga.Name,
|
||||
Role: orga.Role,
|
||||
})
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user