修改BUG:MongoDB新建用户使用User类
This commit is contained in:
parent
f216a95c66
commit
b7e1c19e20
|
@ -87,13 +87,20 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
|
||||||
if (user.Description.Length > 500) user.Description = user.Description.Substring(0, 500);
|
if (user.Description.Length > 500) user.Description = user.Description.Substring(0, 500);
|
||||||
if (user.UserName.Length > 50) user.UserName = user.UserName.Substring(0, 50);
|
if (user.UserName.Length > 50) user.UserName = user.UserName.Substring(0, 50);
|
||||||
user.Id = null;
|
MongoDbAccessManager.Users.InsertOne(new User()
|
||||||
user.PassSalt = LgbCryptography.GenerateSalt();
|
{
|
||||||
user.Password = LgbCryptography.ComputeHash(user.Password, user.PassSalt);
|
UserName = user.UserName,
|
||||||
user.RegisterTime = DateTime.Now;
|
DisplayName = user.DisplayName,
|
||||||
user.ApprovedTime = DateTime.Now;
|
PassSalt = LgbCryptography.GenerateSalt(),
|
||||||
user.Icon = $"{DictHelper.RetrieveIconFolderPath().Code}default.jpg";
|
Password = LgbCryptography.ComputeHash(user.Password, user.PassSalt),
|
||||||
MongoDbAccessManager.Users.InsertOne(user as User);
|
RegisterTime = DateTime.Now,
|
||||||
|
ApprovedTime = DateTime.Now,
|
||||||
|
ApprovedBy = user.ApprovedBy,
|
||||||
|
Roles = new List<string>(),
|
||||||
|
Groups = new List<string>(),
|
||||||
|
Icon = $"{DictHelper.RetrieveIconFolderPath().Code}default.jpg",
|
||||||
|
Description = user.Description
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue