Commit da3dcd19 by Leonard Gram

folder: uses service to make user admin of created folder.

parent c8c00409
......@@ -61,6 +61,11 @@ func (hs *HTTPServer) CreateFolder(c *m.ReqContext, cmd m.CreateFolderCommand) R
return toFolderError(err)
}
if hs.Cfg.EditorsCanOwn {
aclService := dashboards.NewAclService()
aclService.MakeUserAdmin(c.OrgId, c.SignedInUser.UserId, cmd.Result.Id)
}
g := guardian.New(cmd.Result.Id, c.OrgId, c.SignedInUser)
return JSON(200, toFolderDto(g, cmd.Result))
}
......
......@@ -5,7 +5,6 @@ import (
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/guardian"
"github.com/grafana/grafana/pkg/services/search"
"time"
)
// FolderService service for operating on folders
......@@ -115,45 +114,6 @@ func (dr *dashboardServiceImpl) CreateFolder(cmd *models.CreateFolderCommand) er
return toFolderError(err)
}
rtEditor := models.ROLE_EDITOR
rtViewer := models.ROLE_VIEWER
items := []*models.DashboardAcl{
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
UserId: saveDashboardCmd.Result.CreatedBy,
Permission: models.PERMISSION_ADMIN,
Created: time.Now(),
Updated: time.Now(),
},
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
Role: &rtEditor,
Permission: models.PERMISSION_EDIT,
Created: time.Now(),
Updated: time.Now(),
},
{
OrgId: dr.orgId,
DashboardId: saveDashboardCmd.Result.Id,
Role: &rtViewer,
Permission: models.PERMISSION_VIEW,
Created: time.Now(),
Updated: time.Now(),
},
}
aclCmd := &models.UpdateDashboardAclCommand{
DashboardId: saveDashboardCmd.Result.Id,
Items: items,
}
if err = bus.Dispatch(aclCmd); err != nil {
return err
}
query := models.GetDashboardQuery{OrgId: dr.orgId, Id: saveDashboardCmd.Result.Id}
dashFolder, err = getFolder(query)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment