This commit is contained in:
Torkel Ödegaard
2014-09-17 09:49:28 +02:00
parent 31fe471da5
commit 2380a26987
5 changed files with 24 additions and 7 deletions
+4 -2
View File
@@ -29,8 +29,9 @@ func (self *HttpServer) getDashboard(c *gin.Context) {
func (self *HttpServer) search(c *gin.Context) {
query := c.Params.ByName("q")
accountId, err := c.Get("accountId")
results, err := self.store.Query(query)
results, err := self.store.Query(query, accountId.(int))
if err != nil {
log.Error("Store query error: %v", err)
c.JSON(500, newErrorResponse("Failed"))
@@ -42,12 +43,13 @@ func (self *HttpServer) search(c *gin.Context) {
func (self *HttpServer) postDashboard(c *gin.Context) {
var command saveDashboardCommand
accountId, _ := c.Get("accountId")
if c.EnsureBody(&command) {
dashboard := models.NewDashboard("test")
dashboard.Data = command.Dashboard
dashboard.Title = dashboard.Data["title"].(string)
dashboard.AccountId = 1
dashboard.AccountId = accountId.(int)
dashboard.UpdateSlug()
if dashboard.Data["id"] != nil {
+11
View File
@@ -51,6 +51,17 @@ func (self *HttpServer) logoutPost(c *gin.Context) {
c.JSON(200, gin.H{"status": "logged out"})
}
type GrafanaReqContext struct {
}
type authenticatedAuthRouteFunc func(c *gin.Context, grc GrafanaReqContext)
func (self *HttpServer) addAuthRoute(route string, handler authenticatedAuthRouteFunc) {
self.router.GET(route, self.auth(), func(c *gin.Context) {
})
}
func (self *HttpServer) auth() gin.HandlerFunc {
return func(c *gin.Context) {
session, _ := sessionStore.Get(c.Request, "grafana-session")