From bf99e3677b3beb5d0e8e52692b6fb53483d1498b Mon Sep 17 00:00:00 2001 From: Parminder Singh Date: Sat, 27 Jul 2019 21:53:10 +0530 Subject: [PATCH] Added error status codes --- clientapi/routing/auth_fallback.go | 2 ++ clientapi/routing/routing.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clientapi/routing/auth_fallback.go b/clientapi/routing/auth_fallback.go index 339fd1f28..411e26e12 100644 --- a/clientapi/routing/auth_fallback.go +++ b/clientapi/routing/auth_fallback.go @@ -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) diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 435c11943..d8f157be5 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -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 {