Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

fixed bug.

Jack7f8fd3d996d3
diff --git a/core/internal/cmd/cmd.go b/core/internal/cmd/cmd.go
index 46bb34c3..8e5a4c33 100644
--- a/core/internal/cmd/cmd.go
+++ b/core/internal/cmd/cmd.go
@@ -24,7 +24,6 @@ import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
- "github.com/gogf/gf/v2/os/gsession"
"net/http/httputil"
"net/url"
"path/filepath"
@@ -82,20 +81,27 @@ var (
s := g.Server(consts.DEFAULT_SERVER_NAME)
// Use Redis for session storage
- s.SetSessionStorage(gsession.NewStorageRedis(g.Redis()))
+ // s.SetSessionStorage(gsession.NewStorageRedis(g.Redis()))
// Bind Server Hooks
s.BindHookHandlerByMap("/*", map[ghttp.HookName]ghttp.HandlerFunc{
ghttp.HookBeforeServe: func(r *ghttp.Request) {
// Safe path check
if safepath != "" {
- if !r.IsFileRequest() && !strings.HasPrefix(r.URL.Path, "/api/") {
+ if r.URL.Path == "/"+safepath {
+ // Set session
+ err := r.Session.Set("safe_path_pass", true)
+
+ if err != nil {
+ g.Log().Error(ctx, "set safe_path_pass failed ", err)
+ }
+
+ // r.Response.RedirectTo("/")
+ r.SetCtxVar("JustVisitedSafePath", true)
return
}
- if r.URL.Path == "/"+safepath {
- // Set session
- _ = r.Session.Set("safe_path_pass", true)
+ if !r.IsFileRequest() && !strings.HasPrefix(r.URL.Path, "/api/") {
return
}
@@ -105,6 +111,7 @@ var (
resp.Msg = "access denied"
r.Response.WriteJson(resp)
} else {
+ g.Log().Debug(ctx, "Safe path not passed ", r.URL.Path)
r.Response.WriteHeader(404)
}
r.ExitAll()
@@ -187,9 +194,7 @@ var (
// Add static file handler
s.BindHandler("/*any", func(r *ghttp.Request) {
- subpath := r.Get("any").String()
-
- if subpath == safepath {
+ if r.GetCtxVar("JustVisitedSafePath", false).Bool() {
r.Response.RedirectTo("/")
return
}