fix: 自助修改密码后断开 VPN 连接并登出所有 Web 会话
- auth.go: ChangePassword 失效所有会话(不再排除当前会话),调用 KickUser 断开 VPN 隧道 - ProfileView.vue: 改密成功后 logout 清除 token,跳转登录页并携带 msg 参数 - LoginView.vue: 读取 query.msg 显示"密码已修改,请重新登录"绿色提示 - zh.ts/en.ts: 新增 login.passwordChanged 国际化 key
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"lmvpn/internal/db"
|
||||
"lmvpn/internal/middleware"
|
||||
"lmvpn/internal/model"
|
||||
"lmvpn/internal/vpn"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
@@ -143,8 +144,11 @@ func ChangePassword(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
sessionID, _ := c.Get("session_id")
|
||||
db.DB.Model(&model.Session{}).Where("user_id = ? AND session_id != ?", userID, sessionID).Update("invalid", true)
|
||||
db.DB.Model(&model.Session{}).Where("user_id = ?", userID).Update("invalid", true)
|
||||
|
||||
if vpn.VPN != nil && vpn.VPN.Running() {
|
||||
vpn.VPN.KickUser(user.ID)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "密码修改成功"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user