Don't change realm between auth requests

This commit is contained in:
nemunaire 2018-09-18 19:46:15 +02:00
parent d4fd18bff3
commit 299140dab1
2 changed files with 2 additions and 2 deletions

2
api.go
View File

@ -57,7 +57,7 @@ func (a apiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if f.AuthFunction(user, sURL[1:]) { if f.AuthFunction(user, sURL[1:]) {
ret, err = f.DispatchFunction(user, sURL[1:], r.Body) ret, err = f.DispatchFunction(user, sURL[1:], r.Body)
} else { } else {
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m API\"") w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m\"")
http.Error(w, "{errmsg:\"You are not allowed to do this request.\"}", http.StatusUnauthorized) http.Error(w, "{errmsg:\"You are not allowed to do this request.\"}", http.StatusUnauthorized)
return return
} }

View File

@ -93,7 +93,7 @@ func main() {
mux.HandleFunc("/admin/", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/admin/", func(w http.ResponseWriter, r *http.Request) {
if authFunc(r) == nil { if authFunc(r) == nil {
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m Admin\"") w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m\"")
http.Error(w, "You are not allowed to perform this request.", http.StatusUnauthorized) http.Error(w, "You are not allowed to perform this request.", http.StatusUnauthorized)
} else { } else {
http.ServeFile(w, r, filepath.Join(staticDir, "admin.html")) http.ServeFile(w, r, filepath.Join(staticDir, "admin.html"))