Added error status codes

This commit is contained in:
Parminder Singh 2019-07-27 21:53:10 +05:30
parent 0973dfc4d6
commit bf99e3677b
2 changed files with 3 additions and 1 deletions

View file

@ -109,6 +109,7 @@ func AuthFallback(
sessionID := req.URL.Query().Get("session")
if sessionID == "" {
w.WriteHeader(http.StatusBadRequest)
_, err := w.Write([]byte("Session ID not provided"))
if err != nil {
res := httputil.LogThenError(req, err)
@ -135,6 +136,7 @@ func AuthFallback(
// Handle Recaptcha
if authType == authtypes.LoginTypeRecaptcha {
if cfg.Matrix.RecaptchaPublicKey == "" {
w.WriteHeader(http.StatusInternalServerError)
_, err := w.Write([]byte("This Homeserver doesn't have a recaptcha public key"))
if err != nil {
res := httputil.LogThenError(req, err)

View file

@ -241,7 +241,7 @@ func Setup(
vars := mux.Vars(req)
return AuthFallback(w, req, vars["authType"], cfg)
}),
).Methods("GET", "POST", "OPTIONS")
).Methods(http.MethodGet, http.MethodPost, http.MethodOptions)
r0mux.Handle("/pushrules/",
common.MakeExternalAPI("push_rules", func(req *http.Request) util.JSONResponse {