From a170a234b2a53776b4caa380b20e42b2fe1f2463 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 10 Jul 2026 13:17:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AE=A1=E7=90=86=E5=91=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E5=90=8E=E6=96=AD?= =?UTF-8?q?=E5=BC=80=E5=AF=B9=E5=BA=94=20VPN=20=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UpdateUser 在改密/改角色/禁用用户时,失效 Web 会话的同时调用 KickUser 断开 VPN 隧道,与 ChangePassword 行为对齐。 --- internal/handler/user.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/handler/user.go b/internal/handler/user.go index ff5b3f3..680afe1 100644 --- a/internal/handler/user.go +++ b/internal/handler/user.go @@ -7,6 +7,7 @@ import ( "lmvpn/internal/db" "lmvpn/internal/model" + "lmvpn/internal/vpn" "github.com/gin-gonic/gin" "golang.org/x/crypto/bcrypt" @@ -192,6 +193,9 @@ func UpdateUser(c *gin.Context) { if req.Password != "" || req.Role != "" || req.Status != nil { db.DB.Model(&model.Session{}).Where("user_id = ?", id).Update("invalid", true) + if vpn.VPN != nil && vpn.VPN.Running() { + vpn.VPN.KickUser(uint(id)) + } } db.DB.First(&user, id)