Bläddra i källkod

must return json response from /api/login/ping

Even though http error 401 was returned, the result was still a http 200
Marcus Efraimsson 6 år sedan
förälder
incheckning
dd5a8275f1
1 ändrade filer med 5 tillägg och 4 borttagningar
  1. 5 4
      pkg/api/login.go

+ 5 - 4
pkg/api/login.go

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