qa: Fix JSON in auth requests
This commit is contained in:
parent
7c2e97740f
commit
9fd5564410
@ -37,16 +37,16 @@ func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, htt
|
|||||||
if ficteam == "" {
|
if ficteam == "" {
|
||||||
log.Printf("%s 401 \"%s %s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent())
|
log.Printf("%s 401 \"%s %s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent())
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:\"Need to authenticate.\"}"), http.StatusUnauthorized)
|
http.Error(w, fmt.Sprintf("{\"errmsg\":\"Need to authenticate.\"}"), http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
} else if teamid, err = strconv.ParseInt(ficteam, 10, 64); err != nil {
|
} else if teamid, err = strconv.ParseInt(ficteam, 10, 64); err != nil {
|
||||||
if lnk, err := os.Readlink(path.Join(TeamsDir, ficteam)); err != nil {
|
if lnk, err := os.Readlink(path.Join(TeamsDir, ficteam)); err != nil {
|
||||||
log.Printf("[ERR] Unable to readlink %q: %s\n", path.Join(TeamsDir, ficteam), err)
|
log.Printf("[ERR] Unable to readlink %q: %s\n", path.Join(TeamsDir, ficteam), err)
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:\"Unable to validate authentication.\"}"), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("{\"errmsg\":\"Unable to validate authentication.\"}"), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
} else if teamid, err = strconv.ParseInt(lnk, 10, 64); err != nil {
|
} else if teamid, err = strconv.ParseInt(lnk, 10, 64); err != nil {
|
||||||
log.Printf("[ERR] Error during ParseInt team %q: %s\n", lnk, err)
|
log.Printf("[ERR] Error during ParseInt team %q: %s\n", lnk, err)
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:\"Unable to validate authentication.\"}"), http.StatusInternalServerError)
|
http.Error(w, fmt.Sprintf("{\"errmsg\":\"Unable to validate authentication.\"}"), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, htt
|
|||||||
|
|
||||||
// Read the body
|
// Read the body
|
||||||
if r.ContentLength < 0 || r.ContentLength > 6553600 {
|
if r.ContentLength < 0 || r.ContentLength > 6553600 {
|
||||||
http.Error(w, fmt.Sprintf("{errmsg:\"Request too large or request size unknown\"}"), http.StatusRequestEntityTooLarge)
|
http.Error(w, fmt.Sprintf("{\"errmsg\":\"Request too large or request size unknown\"}"), http.StatusRequestEntityTooLarge)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var body []byte
|
var body []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user