修复潜在危害

This commit is contained in:
Yezi 2023-03-30 15:24:46 +08:00 committed by GitHub
parent 255e76386c
commit 7d24023a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,6 @@ namespace Milimoe.FunGame.Desktop.Model
{ {
private static SocketObject Work; private static SocketObject Work;
private static bool Working = false; private static bool Working = false;
private static bool Success = false;
public LoginModel() : base(RunTime.Socket) public LoginModel() : base(RunTime.Socket)
{ {
@ -28,11 +27,13 @@ namespace Milimoe.FunGame.Desktop.Model
public override void SocketHandler(SocketObject SocketObject) public override void SocketHandler(SocketObject SocketObject)
{ {
try try
{
if (SocketObject.SocketType == SocketMessageType.Login || SocketObject.SocketType == SocketMessageType.CheckLogin)
{ {
Work = SocketObject; Work = SocketObject;
Success = true;
Working = false; Working = false;
} }
}
catch (Exception e) catch (Exception e)
{ {
RunTime.WritelnSystemInfo(e.GetErrorInfo()); RunTime.WritelnSystemInfo(e.GetErrorInfo());
@ -53,9 +54,9 @@ namespace Milimoe.FunGame.Desktop.Model
if (objs.Length > 1) password = (string)objs[1]; if (objs.Length > 1) password = (string)objs[1];
if (objs.Length > 2) autokey = (string)objs[2]; if (objs.Length > 2) autokey = (string)objs[2];
password = password.Encrypt(username); password = password.Encrypt(username);
SetWorking();
if (Socket.Send(SocketMessageType.Login, username, password, autokey) == SocketResult.Success) if (Socket.Send(SocketMessageType.Login, username, password, autokey) == SocketResult.Success)
{ {
SetWorking();
string ErrorMsg = ""; string ErrorMsg = "";
Guid CheckLoginKey = Guid.Empty; Guid CheckLoginKey = Guid.Empty;
(CheckLoginKey, ErrorMsg) = await Task.Factory.StartNew(GetCheckLoginKeyAsync); (CheckLoginKey, ErrorMsg) = await Task.Factory.StartNew(GetCheckLoginKeyAsync);
@ -64,9 +65,9 @@ namespace Milimoe.FunGame.Desktop.Model
ShowMessage.ErrorMessage(ErrorMsg, "登录失败"); ShowMessage.ErrorMessage(ErrorMsg, "登录失败");
return false; return false;
} }
SetWorking();
if (Socket.Send(SocketMessageType.CheckLogin, CheckLoginKey) == SocketResult.Success) if (Socket.Send(SocketMessageType.CheckLogin, CheckLoginKey) == SocketResult.Success)
{ {
SetWorking();
DataSet ds = await Task.Factory.StartNew(GetLoginUserAsync); DataSet ds = await Task.Factory.StartNew(GetLoginUserAsync);
if (ds != null) if (ds != null)
{ {
@ -96,7 +97,7 @@ namespace Milimoe.FunGame.Desktop.Model
{ {
if (!Working) break; if (!Working) break;
} }
if (Success) if (Work != null)
{ {
// 返回一个确认登录的Key // 返回一个确认登录的Key
if (Work.Length > 0) key = Work.GetParam<Guid>(0); if (Work.Length > 0) key = Work.GetParam<Guid>(0);
@ -124,7 +125,7 @@ namespace Milimoe.FunGame.Desktop.Model
{ {
if (!Working) break; if (!Working) break;
} }
if (Success) if (Work != null)
{ {
// 返回构造User对象的DataTable // 返回构造User对象的DataTable
if (Work.Length > 0) ds = Work.GetParam<DataSet>(0); if (Work.Length > 0) ds = Work.GetParam<DataSet>(0);
@ -141,7 +142,6 @@ namespace Milimoe.FunGame.Desktop.Model
private static void SetWorking() private static void SetWorking()
{ {
Working = true; Working = true;
Success = false;
Work = default; Work = default;
} }
} }