mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2026-02-03 06:03:25 +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 {
|
||||
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)
|
||||
return
|
||||
}
|
||||
@@ -1354,10 +1354,13 @@ func (s *Server) basicAuthHandler(h http.Handler) http.HandlerFunc {
|
||||
}
|
||||
|
||||
username, password, authOK := r.BasicAuth()
|
||||
if authOK {
|
||||
if !authorized && username == s.authUser && password == s.authPass {
|
||||
authorized = true
|
||||
}
|
||||
if !authOK && !authorized {
|
||||
http.Error(w, "Not authorized", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if !authorized && username == s.authUser && password == s.authPass {
|
||||
authorized = true
|
||||
}
|
||||
|
||||
if !authorized && s.htpasswdFile != nil {
|
||||
|
||||
Reference in New Issue
Block a user