mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
允许单个账号在同一个IP登录多个客户端
This commit is contained in:
@@ -73,7 +73,7 @@ func (this *SessionManager) Read(sid string) map[string]string {
|
|||||||
|
|
||||||
func (this *SessionManager) WriteItem(sid string, key string, value string) bool {
|
func (this *SessionManager) WriteItem(sid string, key string, value string) bool {
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
defer ttlcache.DefaultCache.Delete( "SESSION@" + sid)
|
defer ttlcache.DefaultCache.Delete("SESSION@" + sid)
|
||||||
|
|
||||||
// 忽略OTP
|
// 忽略OTP
|
||||||
if strings.HasSuffix(sid, "_otp") {
|
if strings.HasSuffix(sid, "_otp") {
|
||||||
@@ -99,7 +99,7 @@ func (this *SessionManager) WriteItem(sid string, key string, value string) bool
|
|||||||
|
|
||||||
func (this *SessionManager) Delete(sid string) bool {
|
func (this *SessionManager) Delete(sid string) bool {
|
||||||
// 删除缓存
|
// 删除缓存
|
||||||
defer ttlcache.DefaultCache.Delete( "SESSION@" + sid)
|
defer ttlcache.DefaultCache.Delete("SESSION@" + sid)
|
||||||
|
|
||||||
// 忽略OTP
|
// 忽略OTP
|
||||||
if strings.HasSuffix(sid, "_otp") {
|
if strings.HasSuffix(sid, "_otp") {
|
||||||
|
|||||||
@@ -237,15 +237,27 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 写入SESSION
|
// 写入SESSION
|
||||||
|
var currentIP = loginutils.RemoteIP(&this.ActionObject)
|
||||||
var localSid = rands.HexString(32)
|
var localSid = rands.HexString(32)
|
||||||
this.Data["localSid"] = localSid
|
this.Data["localSid"] = localSid
|
||||||
this.Data["ip"] = loginutils.RemoteIP(&this.ActionObject)
|
this.Data["ip"] = currentIP
|
||||||
params.Auth.StoreAdmin(adminId, params.Remember, localSid)
|
params.Auth.StoreAdmin(adminId, params.Remember, localSid)
|
||||||
|
|
||||||
|
// 清理老的SESSION
|
||||||
|
_, err = this.RPC().LoginSessionRPC().ClearOldLoginSessions(this.AdminContext(), &pb.ClearOldLoginSessionsRequest{
|
||||||
|
Sid: this.Session().Sid,
|
||||||
|
Ip: currentIP,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 记录日志
|
// 记录日志
|
||||||
err = dao.SharedLogDAO.CreateAdminLog(rpcClient.Context(adminId), oplogs.LevelInfo, this.Request.URL.Path, langs.DefaultMessage(codes.AdminLogin_LogSuccess, params.Username), loginutils.RemoteIP(&this.ActionObject), codes.AdminLogin_LogSuccess, []any{params.Username})
|
err = dao.SharedLogDAO.CreateAdminLog(rpcClient.Context(adminId), oplogs.LevelInfo, this.Request.URL.Path, langs.DefaultMessage(codes.AdminLogin_LogSuccess, params.Username), loginutils.RemoteIP(&this.ActionObject), codes.AdminLogin_LogSuccess, []any{params.Username})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.PrintError(err)
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
Reference in New Issue
Block a user