diff --git a/Bootstrap.DataAccess/Helper/LoginHelper.cs b/Bootstrap.DataAccess/Helper/LoginHelper.cs index 5b3cd207..05a3a84f 100644 --- a/Bootstrap.DataAccess/Helper/LoginHelper.cs +++ b/Bootstrap.DataAccess/Helper/LoginHelper.cs @@ -19,6 +19,7 @@ namespace Bootstrap.DataAccess public static bool Log(LoginUser user) { if (user.Id == string.Empty) user.Id = null; + if (string.IsNullOrEmpty(user.UserName)) user.UserName = user.Ip; return DbContextManager.Create().Log(user); } diff --git a/Bootstrap.DataAccess/Helper/UserHelper.cs b/Bootstrap.DataAccess/Helper/UserHelper.cs index e70e65c3..73c2d900 100644 --- a/Bootstrap.DataAccess/Helper/UserHelper.cs +++ b/Bootstrap.DataAccess/Helper/UserHelper.cs @@ -52,7 +52,7 @@ namespace Bootstrap.DataAccess Result = "登录失败" }; config(loginUser); - var ret = DbContextManager.Create().Authenticate(userName, password); + var ret = string.IsNullOrEmpty(userName) ? false : DbContextManager.Create().Authenticate(userName, password); if (ret) loginUser.Result = "登录成功"; LoginHelper.Log(loginUser); return ret;