fix(#IX3JR): 修复用户名为空时触发数据库异常

#Comment
comment #IX3JR

#Issue
close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IX3JR
This commit is contained in:
Argo Zhang 2019-05-28 11:31:58 +08:00
parent 22b863ff24
commit 89478672bd
2 changed files with 2 additions and 1 deletions

View File

@ -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<LoginUser>().Log(user);
}

View File

@ -52,7 +52,7 @@ namespace Bootstrap.DataAccess
Result = "登录失败"
};
config(loginUser);
var ret = DbContextManager.Create<User>().Authenticate(userName, password);
var ret = string.IsNullOrEmpty(userName) ? false : DbContextManager.Create<User>().Authenticate(userName, password);
if (ret) loginUser.Result = "登录成功";
LoginHelper.Log(loginUser);
return ret;