mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Remove org methods from sqlstore interface (#56358)
* Remove org methods from sqlstore interface * Remove some mocks * Fix some tests
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/login"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
@@ -286,26 +287,28 @@ func (hs *HTTPServer) GetUserOrgList(c *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) getUserOrgList(ctx context.Context, userID int64) response.Response {
|
||||
query := models.GetUserOrgListQuery{UserId: userID}
|
||||
query := org.GetUserOrgListQuery{UserID: userID}
|
||||
|
||||
if err := hs.SQLStore.GetUserOrgList(ctx, &query); err != nil {
|
||||
result, err := hs.orgService.GetUserOrgList(ctx, &query)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to get user organizations", err)
|
||||
}
|
||||
|
||||
return response.JSON(http.StatusOK, query.Result)
|
||||
return response.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) validateUsingOrg(ctx context.Context, userID int64, orgID int64) bool {
|
||||
query := models.GetUserOrgListQuery{UserId: userID}
|
||||
query := org.GetUserOrgListQuery{UserID: userID}
|
||||
|
||||
if err := hs.SQLStore.GetUserOrgList(ctx, &query); err != nil {
|
||||
result, err := hs.orgService.GetUserOrgList(ctx, &query)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// validate that the org id in the list
|
||||
valid := false
|
||||
for _, other := range query.Result {
|
||||
if other.OrgId == orgID {
|
||||
for _, other := range result {
|
||||
if other.OrgID == orgID {
|
||||
valid = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user