修复账户登录失败,服务器不进行失败计数的BUG,v1.4.8

This commit is contained in:
dathlin
2017-09-24 20:53:38 +08:00
parent e8a72078c3
commit f226e00fb9
2 changed files with 20 additions and 6 deletions

View File

@@ -13,6 +13,8 @@ namespace CommonLibrary
/// <typeparam name="T">账户类该类必须派生自UserAccount类</typeparam> /// <typeparam name="T">账户类该类必须派生自UserAccount类</typeparam>
public class ServerAccounts<T> : HslCommunication.BasicFramework.SoftFileSaveBase where T : UserAccount, new() public class ServerAccounts<T> : HslCommunication.BasicFramework.SoftFileSaveBase where T : UserAccount, new()
{ {
#region Constructor
/// <summary> /// <summary>
/// 初始化构造方法 /// 初始化构造方法
/// </summary> /// </summary>
@@ -28,14 +30,20 @@ namespace CommonLibrary
all_list_accounts.AddRange(accounts); all_list_accounts.AddRange(accounts);
} }
private List<T> all_list_accounts = new List<T>(); #endregion
#region Private Member
private List<T> all_list_accounts = new List<T>();
/// <summary> /// <summary>
/// 一个简单的混合锁相比Lock速度更快 /// 一个简单的混合锁相比Lock速度更快
/// </summary> /// </summary>
private HslCommunication.SimpleHybirdLock hybirdLock = new HslCommunication.SimpleHybirdLock(); private HslCommunication.SimpleHybirdLock hybirdLock = new HslCommunication.SimpleHybirdLock();
#endregion
#region Public Method
/// <summary> /// <summary>
/// 更新指定账户的密码 /// 更新指定账户的密码
/// </summary> /// </summary>
@@ -126,15 +134,16 @@ namespace CommonLibrary
{ {
if (item.Password != code) if (item.Password != code)
{ {
item.LoginFailedCount++;
result.ForbidMessage = "密码错误!"; result.ForbidMessage = "密码错误!";
break; break;
} }
else else
{ {
//说明已经登录成功,需要进行进一步操作 // 说明已经登录成功,需要进行进一步操作
item.LoginFrequency++; item.LoginFrequency++;
result = item.DeepCopy<T>(); result = item.DeepCopy<T>();
//下面两个数据应该是旧的数据 // 下面两个数据应该是旧的数据
item.LastLoginIpAddress = ipAddress; item.LastLoginIpAddress = ipAddress;
item.LastLoginTime = DateTime.Now; item.LastLoginTime = DateTime.Now;
item.LastLoginWay = way; item.LastLoginWay = way;
@@ -161,7 +170,7 @@ namespace CommonLibrary
/// 新增一个账户如果账户名称已经存在则返回False注册成功返回True /// 新增一个账户如果账户名称已经存在则返回False注册成功返回True
/// </summary> /// </summary>
/// <param name="account">账户对象</param> /// <param name="account">账户对象</param>
/// <returns>成功True,失败False</returns> /// <returns>成功<c>True</c>,失败<c>False</c></returns>
public bool AddNewAccount(T account) public bool AddNewAccount(T account)
{ {
bool result = true; bool result = true;
@@ -246,7 +255,9 @@ namespace CommonLibrary
hybirdLock.Leave(); hybirdLock.Leave();
} }
#endregion
#region Override Method
@@ -280,5 +291,8 @@ namespace CommonLibrary
{ {
SaveToFile(m => m); SaveToFile(m => m);
} }
#endregion
} }
} }

View File

@@ -43,7 +43,7 @@ namespace CommonLibrary
* *
**************************************************************************/ **************************************************************************/
SoftBasic.FrameworkVersion = new SystemVersion("1.4.7"); SoftBasic.FrameworkVersion = new SystemVersion("1.4.8");
} }