Bladeren bron

now /api/login/ping returns Response

Marcus Efraimsson 6 jaren geleden
bovenliggende
commit
cfd8eb5167
2 gewijzigde bestanden met toevoegingen van 6 en 7 verwijderingen
  1. 2 2
      pkg/api/api.go
  2. 4 5
      pkg/api/login.go

+ 2 - 2
pkg/api/api.go

@@ -108,8 +108,8 @@ func (hs *HTTPServer) registerRoutes() {
 	r.Get("/api/snapshots-delete/:deleteKey", Wrap(DeleteDashboardSnapshotByDeleteKey))
 	r.Delete("/api/snapshots/:key", reqEditorRole, Wrap(DeleteDashboardSnapshot))
 
-	// api renew session based on remember cookie
-	r.Get("/api/login/ping", quota("session"), hs.LoginAPIPing)
+	// api renew session based on cookie
+	r.Get("/api/login/ping", quota("session"), Wrap(hs.LoginAPIPing))
 
 	// authed api
 	r.Group("/api", func(apiRoute routing.RouteRegister) {

+ 4 - 5
pkg/api/login.go

@@ -78,13 +78,12 @@ func tryOAuthAutoLogin(c *m.ReqContext) bool {
 	return false
 }
 
-func (hs *HTTPServer) LoginAPIPing(c *m.ReqContext) {
-	if c.IsSignedIn || (c.AllowAnonymous && c.IsAnonymous) {
-		c.JsonOK("Logged in")
-		return
+func (hs *HTTPServer) LoginAPIPing(c *m.ReqContext) Response {
+	if c.IsSignedIn || c.IsAnonymous {
+		return JSON(200, "Logged in")
 	}
 
-	c.JsonApiErr(401, "Unauthorized", nil)
+	return Error(401, "Unauthorized", nil)
 }
 
 func (hs *HTTPServer) LoginPost(c *m.ReqContext, cmd dtos.LoginCommand) Response {