Skip to content

Commit

Permalink
中间件判断逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
csznet committed Apr 9, 2024
1 parent 2f0d9c6 commit 163e85b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func Middleware(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// 只有当密码设置并且不为"none"时,才进行检查
if conf.Pass != "" && conf.Pass != "none" {
if cookie, err := r.Cookie("p"); err != nil || cookie.Value != conf.Pass || r.URL.Path == "/api" && r.URL.Query().Get("pass") != conf.Pass {
if cookie, err := r.Cookie("p"); err != nil || cookie.Value != conf.Pass || strings.HasPrefix(r.URL.Path, "/api") && r.URL.Query().Get("pass") != conf.Pass {
http.Redirect(w, r, "/pwd", http.StatusSeeOther)
return
}
Expand Down

0 comments on commit 163e85b

Please sign in to comment.