refactor: 更新 MongoDB 用户名查找时忽略大小写

This commit is contained in:
Argo-Cloud 2020-10-26 17:33:47 +08:00
parent ec87210310
commit 23015c318a
1 changed files with 2 additions and 2 deletions

View File

@ -156,7 +156,7 @@ namespace Bootstrap.DataAccess.MongoDB
var passSalt = LgbCryptography.GenerateSalt();
var newPassword = LgbCryptography.ComputeHash(newPass, passSalt);
var update = Builders<User>.Update.Set(u => u.Password, newPassword).Set(u => u.PassSalt, passSalt);
DbManager.Users.FindOneAndUpdate(u => u.UserName == UserName, update);
DbManager.Users.FindOneAndUpdate(u => u.UserName.ToUpperInvariant() == UserName.ToUpperInvariant(), update);
ret = true;
}
return ret;
@ -275,7 +275,7 @@ namespace Bootstrap.DataAccess.MongoDB
var passSalt = LgbCryptography.GenerateSalt();
var newPassword = LgbCryptography.ComputeHash(password, passSalt);
DbManager.Users.UpdateOne(User => User.UserName.ToLowerInvariant() == userName.ToLowerInvariant(), Builders<User>.Update.Set(md => md.Password, newPassword).Set(md => md.PassSalt, passSalt).Set(md => md.IsReset, 0));
DbManager.ResetUsers.DeleteMany(user => user.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
DbManager.ResetUsers.DeleteMany(user => user.UserName.ToUpperInvariant() == userName.ToUpperInvariant());
return true;
}