mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-06 01:06:26 +08:00
correct header and format for json decoding of error (#411)
This commit is contained in:
committed by
Jesse Peterson
parent
a56ff7d295
commit
8118bf6333
@@ -903,7 +903,9 @@ func apiAuthMiddleware(token string, next http.Handler) http.HandlerFunc {
|
||||
_, password, ok := r.BasicAuth()
|
||||
if !ok || password != token {
|
||||
w.Header().Set("WWW-Authenticate", `Basic realm="micromdm"`)
|
||||
http.Error(w, `{"error": "you need to log in"}`, http.StatusUnauthorized)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.Write([]byte(`{"error": "you need to log in"}`))
|
||||
return
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
Reference in New Issue
Block a user