mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2026-02-03 14:13:26 +00:00
better logic
This commit is contained in:
@@ -1326,7 +1326,7 @@ func ipFilterHandler(h http.Handler, ipFilterOptions *IPFilterOptions) http.Hand
|
|||||||
|
|
||||||
func (s *Server) basicAuthHandler(h http.Handler) http.HandlerFunc {
|
func (s *Server) basicAuthHandler(h http.Handler) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
if (s.authUser == "" || s.authPass == "") && s.authHtpasswd == "" {
|
if s.authUser == "" && s.authPass == "" && s.authHtpasswd == "" {
|
||||||
h.ServeHTTP(w, r)
|
h.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1354,10 +1354,13 @@ func (s *Server) basicAuthHandler(h http.Handler) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
username, password, authOK := r.BasicAuth()
|
username, password, authOK := r.BasicAuth()
|
||||||
if authOK {
|
if !authOK && !authorized {
|
||||||
if !authorized && username == s.authUser && password == s.authPass {
|
http.Error(w, "Not authorized", http.StatusUnauthorized)
|
||||||
authorized = true
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !authorized && username == s.authUser && password == s.authPass {
|
||||||
|
authorized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !authorized && s.htpasswdFile != nil {
|
if !authorized && s.htpasswdFile != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user