From e4d82673da3b466a2795bae5d2227726cc06365b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sun, 21 Mar 2021 21:32:52 +0100 Subject: [PATCH] fix 401 and 403 texts. --- internal/http/auth/auth.go | 8 ++++---- internal/utils/http.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/http/auth/auth.go b/internal/http/auth/auth.go index 6de99f4a..22dbc475 100644 --- a/internal/http/auth/auth.go +++ b/internal/http/auth/auth.go @@ -27,7 +27,7 @@ func AdminsOnly(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { session := GetSession(r) if !session.Profile().IsAdmin { - utils.HttpForbidden(w) + utils.HttpForbidden(w, "Only admin can do this.") } else { next.ServeHTTP(w, r) } @@ -49,7 +49,7 @@ func CanWatchOnly(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { session := GetSession(r) if !session.Profile().CanWatch { - utils.HttpForbidden(w, "Only for sessions, that can watch.") + utils.HttpForbidden(w, "Only sessions, that can watch.") } else { next.ServeHTTP(w, r) } @@ -60,7 +60,7 @@ func CanHostOnly(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { session := GetSession(r) if !session.Profile().CanHost { - utils.HttpForbidden(w, "Only for sessions, that can host.") + utils.HttpForbidden(w, "Only sessions, that can host.") } else { next.ServeHTTP(w, r) } @@ -71,7 +71,7 @@ func CanAccessClipboardOnly(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { session := GetSession(r) if !session.Profile().CanAccessClipboard { - utils.HttpForbidden(w, "Only for sessions, that can access clipboard.") + utils.HttpForbidden(w, "Only sessions, that can access clipboard.") } else { next.ServeHTTP(w, r) } diff --git a/internal/utils/http.go b/internal/utils/http.go index 11debe8c..f85008f4 100644 --- a/internal/utils/http.go +++ b/internal/utils/http.go @@ -57,11 +57,11 @@ func HttpBadRequest(w http.ResponseWriter, res ...interface{}) { } func HttpUnauthorized(w http.ResponseWriter, res ...interface{}) { - defHttpError(w, http.StatusUnauthorized, "Access token does not have the required scope.", res...) + defHttpError(w, http.StatusUnauthorized, "Invalid or missing access token.", res...) } func HttpForbidden(w http.ResponseWriter, res ...interface{}) { - defHttpError(w, http.StatusForbidden, "Invalid or missing access token.", res...) + defHttpError(w, http.StatusForbidden, "Access token does not have the required scope.", res...) } func HttpNotFound(w http.ResponseWriter, res ...interface{}) {