山东网站空间,广告网站开发背景,网页升级紧急通知每天正常更新,制作网站开发因为ABP Vnext在密码加密方面使用的盐加密的方式#xff0c;底层的加密方式让人摸不着头脑。如何需要批量导入用户的时候#xff0c;这个密码问题就很头疼。假设#xff0c;已经有一个集合Listentity的用户数据了#xff0c;此时进行循环取出一条用户信息#xff…因为ABP Vnext在密码加密方面使用的盐加密的方式底层的加密方式让人摸不着头脑。如何需要批量导入用户的时候这个密码问题就很头疼。假设已经有一个集合Listentity的用户数据了此时进行循环取出一条用户信息进行 abpUser实体的转换。代码如下//判断密码字段是否为空if (string.IsNullOrEmpty(entity.PasswordHash)){entity.Remark 密码不能为空;entityRepeatList.Add(entity);continue;}//这是扩展字段的信息如果没有可以删除entity.SetProperty(EmpNo, entity.EmpNo);entity.SetProperty(WeChat, entity.WeChat);await _identityOptions.SetAsync();//UsersInfoDto 自己模仿着 IdentityUser 写一个var user ObjectMapper.MapUsersInfoDto, Volo.Abp.Identity.IdentityUser(entity);entity.PasswordHash _passwordHasher.HashPassword(user, entity.PasswordHash);var userPasswordHash ObjectMapper.MapUsersInfoDto, Volo.Abp.Identity.IdentityUser(entity);await _identityUserRepository.InsertAsync(userPasswordHash);//此时插入数据并不立即生效没有触发savachange(),本接口遍历完毕才触发保存所以不用担心每次重复打开关闭连接池的问题用到的构造函数如下private readonly IOptionsIdentityOptions _identityOptions;private readonly IPasswordHasherVolo.Abp.Identity.IdentityUser _passwordHasher;最重要的一点是using引用命名空间的时候优先选择 Volo.Abp.xxx的命名不要选择using Microsoft.AspNetCore.Identity....微软自带的因为abp默认继承了Microsoft会造成代码冲突。