[Audited]
[AuditExpansion(nameof(TenantId), typeof(Tenant), nameof(RmoniWeb.MultiTenancy.Tenant.Name))]
public class User : AbpUser<User>
{
public virtual Guid? ProfilePictureId { get; set; }
public virtual bool ShouldChangePasswordOnNextLogin { get; set; }
public DateTime? SignInTokenExpireTimeUtc { get; set; }
public string SignInToken { get; set; }
public string GoogleAuthenticatorKey { get; set; }
public List<ExtendedUserOrganizationUnit> OrganizationUnits { get; set; }
public ICollection<ReportUserRecipient> ReportUserRecipients { get; set; }
public ICollection<AlarmUserRecipient> AlarmUserRecipients { get; set; }
public ICollection<Device> MobileDevices { get; set; }
public bool IsRecipient { get; set; }
public Tenant Tenant { get; set; }
[ForeignKey("ApplicationLanguage")]
public int? LanguageId { get; set; }
public ApplicationLanguage ApplicationLanguage { get; set; }
//Can add application specific user properties here
public User()
{
IsLockoutEnabled = true;
IsTwoFactorEnabled = true;
}
public static User CreateTenantAdminUser(int tenantId, string emailAddress, string phoneNumber = default)
{
var user = new User
{
TenantId = tenantId,
UserName = AdminUserName,
Name = AdminUserName,
Surname = AdminUserName,
EmailAddress = emailAddress,
PhoneNumber = phoneNumber,
Roles = new List<UserRole>(),
OrganizationUnits = new List<ExtendedUserOrganizationUnit>()
};
user.SetNormalizedNames();
return user;
}
public override void SetNewPasswordResetCode()
{
PasswordResetCode = Guid.NewGuid().ToString("N").Truncate(10).ToUpperInvariant();
}
public void Unlock()
{
AccessFailedCount = 0;
LockoutEndDateUtc = null;
}
public void SetSignInToken()
{
SignInToken = Guid.NewGuid().ToString();
SignInTokenExpireTimeUtc = Clock.Now.AddMinutes(1).ToUniversalTime();
}
}
We recently enabled Entity History in our project. For most entities this seems to work properly aas intended. For (our subclassed entity of) AbpUser this logs duplicates of the audited properties (CreatorUserId, LastModifierUserId, ...) with faulty 'OriginalValue' data.
Row 3 shows the correct update from Id 663 to Id 13493 for the LastModifierUser. Rows 5-9 show faulty entries for the LastModifierUserId, where for some reason the Original Value is a string instead of a long, and does not correspond to the actual original value.
In order to debug this, I tried to subclass the EntityHistoryHelper and override CreateEntityChangeSet, and was able to verify that the returned changeset is correct. So these properties are added later in the flow, either somewhere between the call to CreateEntityChangeSet and the actual save to the db table, or during the actual save.
Hi @ismcagdas, if I follow https://github.com/aspnetzero/aspnet-zero-core/issues/4522#issuecomment-1215365279, I get a "Page Not Found Error". Can you provide the correct URL, please?