From 0acbb05d3f41e159cd1133e1e1b15c04c563bb30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Fri, 13 Jun 2025 02:42:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=89=E5=85=A8=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E6=97=B6=EF=BC=8C=E5=8F=AF=E8=83=BD=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=8F=8D=E5=A4=8D=E8=B7=B3=E8=BD=AC=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/http/middleware/must_login.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/http/middleware/must_login.go b/internal/http/middleware/must_login.go index 3f4e2d1a..d9449ab4 100644 --- a/internal/http/middleware/must_login.go +++ b/internal/http/middleware/must_login.go @@ -65,6 +65,7 @@ func MustLogin(t *gotext.Locale, session *sessions.Manager, userToken biz.UserTo ip, _, _ := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr)) clientHash := fmt.Sprintf("%x", sha256.Sum256([]byte(ip))) if safeClientHash != clientHash || safeClientHash == "" { + sess.Forget("user_id") // 清除 user_id,否则会来回跳转 Abort(w, http.StatusUnauthorized, t.Get("client ip/ua changed, please login again")) return }