diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/UserService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/UserService.cs
index ca822d31..fced9661 100644
--- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/UserService.cs
+++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/System/UserService.cs
@@ -152,7 +152,7 @@ namespace Yi.Framework.Rbac.Application.Services.System
//更新密码,特殊处理
if (input.Password is not null)
{
- entity.Password = input.Password;
+ entity.EncryPassword.Password = input.Password;
entity.BuildPassword();
}
await MapToEntityAsync(input, entity);
diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/UserEntity.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/UserEntity.cs
index 4925273f..fde5de33 100644
--- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/UserEntity.cs
+++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/UserEntity.cs
@@ -4,6 +4,7 @@ using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Yi.Framework.Core.Data;
using Yi.Framework.Core.Helper;
+using Yi.Framework.Rbac.Domain.Entities.ValueObjects;
using Yi.Framework.Rbac.Domain.Shared.Enums;
namespace Yi.Framework.Rbac.Domain.Entities
@@ -22,7 +23,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
public UserEntity(string userName, string password, long phone, string nick = "萌新")
{
UserName = userName;
- Password = password;
+ EncryPassword.Password = password;
Phone = phone;
Nick = nick;
BuildPassword();
@@ -55,14 +56,20 @@ namespace Yi.Framework.Rbac.Domain.Entities
public string UserName { get; set; } = string.Empty;
///
- /// 密码
+ /// 加密密码
///
- public string Password { get; set; } = string.Empty;
+ [SugarColumn(IsOwnsOne = true)]
+ public EncryPasswordValueObject EncryPassword { get; set; }=new EncryPasswordValueObject();
- ///
- /// 加密盐值
- ///
- public string Salt { get; set; } = string.Empty;
+ /////
+ ///// 密码
+ /////
+ //public string Password { get; set; } = string.Empty;
+
+ /////
+ ///// 加密盐值
+ /////
+ //public string Salt { get; set; } = string.Empty;
///
/// 头像
@@ -175,14 +182,14 @@ namespace Yi.Framework.Rbac.Domain.Entities
//如果不传值,那就把自己的password当作传进来的password
if (password == null)
{
- if (Password == null)
+ if (EncryPassword.Password == null)
{
- throw new ArgumentNullException(nameof(Password));
+ throw new ArgumentNullException(nameof(EncryPassword.Password));
}
- password = Password;
+ password = EncryPassword.Password;
}
- Salt = MD5Helper.GenerateSalt();
- Password = MD5Helper.SHA2Encode(password, Salt);
+ EncryPassword.Salt = MD5Helper.GenerateSalt();
+ EncryPassword.Password = MD5Helper.SHA2Encode(password, EncryPassword.Salt);
return this;
}
@@ -193,12 +200,12 @@ namespace Yi.Framework.Rbac.Domain.Entities
///
public bool JudgePassword(string password)
{
- if (Salt is null)
+ if (EncryPassword.Salt is null)
{
- throw new ArgumentNullException(Salt);
+ throw new ArgumentNullException(EncryPassword.Salt);
}
- var p = MD5Helper.SHA2Encode(password, Salt);
- if (Password == MD5Helper.SHA2Encode(password, Salt))
+ var p = MD5Helper.SHA2Encode(password, EncryPassword.Salt);
+ if (EncryPassword.Password == MD5Helper.SHA2Encode(password, EncryPassword.Salt))
{
return true;
}
diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/ValueObjects/EncryPasswordValueObject.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/ValueObjects/EncryPasswordValueObject.cs
new file mode 100644
index 00000000..6c269ba2
--- /dev/null
+++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Entities/ValueObjects/EncryPasswordValueObject.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Domain.Values;
+
+namespace Yi.Framework.Rbac.Domain.Entities.ValueObjects
+{
+ public class EncryPasswordValueObject : ValueObject
+ {
+ ///
+ /// 密码
+ ///
+ public string Password { get; set; } = string.Empty;
+
+ ///
+ /// 加密盐值
+ ///
+ public string Salt { get; set; } = string.Empty;
+
+ protected override IEnumerable