From b939da3668ecb345633735acc50214a14f2ecc63 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 26 Jul 2021 11:51:54 -0600 Subject: [PATCH] adds invited date to back office user --- .../Security/BackOfficeIdentityUser.cs | 10 ++++++++++ .../Security/BackOfficeUserStore.cs | 7 +++++++ .../Security/IdentityMapDefinition.cs | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Infrastructure/Security/BackOfficeIdentityUser.cs b/src/Umbraco.Infrastructure/Security/BackOfficeIdentityUser.cs index 9ddb67d611..e3ddc69e6f 100644 --- a/src/Umbraco.Infrastructure/Security/BackOfficeIdentityUser.cs +++ b/src/Umbraco.Infrastructure/Security/BackOfficeIdentityUser.cs @@ -18,6 +18,7 @@ namespace Umbraco.Cms.Core.Security private string[] _allowedSections; private int[] _startMediaIds; private int[] _startContentIds; + private DateTime? _inviteDateUtc; private static readonly DelegateEqualityComparer s_startIdsComparer = new DelegateEqualityComparer( (groups, enumerable) => groups.UnsortedSequenceEqual(enumerable), @@ -75,6 +76,15 @@ namespace Umbraco.Cms.Core.Security public int[] CalculatedMediaStartNodeIds { get; set; } public int[] CalculatedContentStartNodeIds { get; set; } + /// + /// Gets or sets invite date + /// + public DateTime? InviteDateUtc + { + get => _inviteDateUtc; + set => BeingDirty.SetPropertyValueAndDetectChanges(value, ref _inviteDateUtc, nameof(InviteDateUtc)); + } + /// /// Gets or sets content start nodes assigned to the User (not ones assigned to the user's groups) /// diff --git a/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs b/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs index e6a58efa88..deb85ff496 100644 --- a/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs +++ b/src/Umbraco.Infrastructure/Security/BackOfficeUserStore.cs @@ -438,6 +438,13 @@ namespace Umbraco.Cms.Core.Security user.LastLoginDate = dt; } + if (identityUser.IsPropertyDirty(nameof(BackOfficeIdentityUser.InviteDateUtc)) + || (user.InvitedDate?.ToUniversalTime() != identityUser.InviteDateUtc)) + { + anythingChanged = true; + user.InvitedDate = identityUser.InviteDateUtc?.ToLocalTime(); + } + if (identityUser.IsPropertyDirty(nameof(BackOfficeIdentityUser.LastPasswordChangeDateUtc)) || (user.LastPasswordChangeDate != default && identityUser.LastPasswordChangeDateUtc.HasValue == false) || (identityUser.LastPasswordChangeDateUtc.HasValue && user.LastPasswordChangeDate.ToUniversalTime() != identityUser.LastPasswordChangeDateUtc.Value)) diff --git a/src/Umbraco.Infrastructure/Security/IdentityMapDefinition.cs b/src/Umbraco.Infrastructure/Security/IdentityMapDefinition.cs index 0d0b9fc156..5addc73a3f 100644 --- a/src/Umbraco.Infrastructure/Security/IdentityMapDefinition.cs +++ b/src/Umbraco.Infrastructure/Security/IdentityMapDefinition.cs @@ -74,6 +74,7 @@ namespace Umbraco.Cms.Core.Security target.UserName = source.Username; target.LastPasswordChangeDateUtc = source.LastPasswordChangeDate.ToUniversalTime(); target.LastLoginDateUtc = source.LastLoginDate.ToUniversalTime(); + target.InviteDateUtc = source.InvitedDate?.ToUniversalTime(); target.EmailConfirmed = source.EmailConfirmedDate.HasValue; target.Name = source.Name; target.AccessFailedCount = source.FailedPasswordAttempts; @@ -87,7 +88,7 @@ namespace Umbraco.Cms.Core.Security target.LockoutEnd = source.IsLockedOut ? DateTime.MaxValue.ToUniversalTime() : (DateTime?)null; } - // TODO: We need to validate this mapping is OK, we need to get Umbraco.Code working + // Umbraco.Code.MapAll -Id -LockoutEnabled -PhoneNumber -PhoneNumberConfirmed -TwoFactorEnabled -ConcurrencyStamp -NormalizedEmail -NormalizedUserName -Roles private void Map(IMember source, MemberIdentityUser target) { target.Email = source.Email;