mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-03 04:18:15 +08:00
fix: 用户名或密码修改,将所有登录都退出
This commit is contained in:
parent
252c48bb40
commit
76a0c38327
@ -60,6 +60,9 @@ func (u *SettingService) Update(key, value string) error {
|
||||
if err := settingRepo.Update(key, value); err != nil {
|
||||
return err
|
||||
}
|
||||
if key == "UserName" {
|
||||
_ = global.SESSION.Clean()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -115,13 +118,6 @@ func (u *SettingService) UpdatePassword(c *gin.Context, old, new string) error {
|
||||
if err := u.HandlePasswordExpired(c, old, new); err != nil {
|
||||
return err
|
||||
}
|
||||
sID, _ := c.Cookie(constant.SessionName)
|
||||
if sID != "" {
|
||||
c.SetCookie(constant.SessionName, sID, -1, "", "", false, false)
|
||||
err := global.SESSION.Delete(sID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_ = global.SESSION.Clean()
|
||||
return nil
|
||||
}
|
||||
|
7
backend/init/cache/badger_db/badger_db.go
vendored
7
backend/init/cache/badger_db/badger_db.go
vendored
@ -2,9 +2,10 @@ package badger_db
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/dgraph-io/badger/v3"
|
||||
"github.com/pkg/errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
@ -44,6 +45,10 @@ func (c *Cache) Del(key string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Cache) Clean() error {
|
||||
return c.db.DropAll()
|
||||
}
|
||||
|
||||
func (c *Cache) Get(key string) ([]byte, error) {
|
||||
var result []byte
|
||||
err := c.db.View(func(txn *badger.Txn) error {
|
||||
|
@ -2,8 +2,9 @@ package psession
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/1Panel-dev/1Panel/backend/init/cache/badger_db"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/init/cache/badger_db"
|
||||
)
|
||||
|
||||
type SessionUser struct {
|
||||
@ -40,3 +41,7 @@ func (p *PSession) Set(sessionID string, user SessionUser, ttlSeconds int) error
|
||||
func (p *PSession) Delete(sessionID string) error {
|
||||
return p.store.Del(sessionID)
|
||||
}
|
||||
|
||||
func (p *PSession) Clean() error {
|
||||
return p.store.Clean()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user