修改BUG:修复MongoDB数据库登录名区分大小写问题,详细信息见Issue #IRWKA

This commit is contained in:
Argo-Surface 2019-02-22 11:51:13 +08:00
parent ba432a06b1
commit 707f3b8516
2 changed files with 3 additions and 3 deletions

View File

@ -73,7 +73,7 @@ namespace Bootstrap.DataAccess.MongoDB
public override IEnumerable<string> RetrieveRolesByUserName(string userName) public override IEnumerable<string> RetrieveRolesByUserName(string userName)
{ {
var roles = new List<string>(); var roles = new List<string>();
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName == userName); var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
var role = RoleHelper.Retrieves(); var role = RoleHelper.Retrieves();
roles.AddRange(user.Roles.Select(r => role.FirstOrDefault(rl => rl.Id == r).RoleName)); roles.AddRange(user.Roles.Select(r => role.FirstOrDefault(rl => rl.Id == r).RoleName));

View File

@ -34,7 +34,7 @@ namespace Bootstrap.DataAccess.MongoDB
.Include(u => u.DisplayName) .Include(u => u.DisplayName)
.Include(u => u.Icon) .Include(u => u.Icon)
.Include(u => u.Css); .Include(u => u.Css);
return DbManager.Users.Find(user => user.UserName == userName).Project<DataAccess.User>(project).FirstOrDefault(); return DbManager.Users.Find(user => user.UserName.ToLowerInvariant() == userName.ToLowerInvariant()).Project<DataAccess.User>(project).FirstOrDefault();
} }
/// <summary> /// <summary>
@ -47,7 +47,7 @@ namespace Bootstrap.DataAccess.MongoDB
{ {
if (string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)) return false; if (string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)) return false;
var u = DbManager.Users.Find(user => user.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); var u = DbManager.Users.Find(user => user.UserName.ToLowerInvariant() == userName.ToLowerInvariant()).FirstOrDefault();
return !string.IsNullOrEmpty(u.PassSalt) && u.Password == LgbCryptography.ComputeHash(password, u.PassSalt); return !string.IsNullOrEmpty(u.PassSalt) && u.Password == LgbCryptography.ComputeHash(password, u.PassSalt);
} }