mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	允许单个账号在同一个IP登录多个客户端
This commit is contained in:
		@@ -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