fix: 管理员修改用户信息后断开对应 VPN 连接
UpdateUser 在改密/改角色/禁用用户时,失效 Web 会话的同时调用 KickUser 断开 VPN 隧道,与 ChangePassword 行为对齐。
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"lmvpn/internal/db"
|
"lmvpn/internal/db"
|
||||||
"lmvpn/internal/model"
|
"lmvpn/internal/model"
|
||||||
|
"lmvpn/internal/vpn"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
@@ -192,6 +193,9 @@ func UpdateUser(c *gin.Context) {
|
|||||||
|
|
||||||
if req.Password != "" || req.Role != "" || req.Status != nil {
|
if req.Password != "" || req.Role != "" || req.Status != nil {
|
||||||
db.DB.Model(&model.Session{}).Where("user_id = ?", id).Update("invalid", true)
|
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)
|
db.DB.First(&user, id)
|
||||||
|
|||||||
Reference in New Issue
Block a user