@@ -18,6 +18,7 @@ public class IdentityMapDefinition : IMapDefinition
1818{
1919 private readonly AppCaches _appCaches ;
2020 private readonly IEntityService _entityService ;
21+ private readonly SecuritySettings _securitySettings ;
2122 private readonly GlobalSettings _globalSettings ;
2223 private readonly ILocalizedTextService _textService ;
2324 private readonly ITwoFactorLoginService _twoFactorLoginService ;
@@ -26,28 +27,48 @@ public IdentityMapDefinition(
2627 ILocalizedTextService textService ,
2728 IEntityService entityService ,
2829 IOptions < GlobalSettings > globalSettings ,
30+ IOptions < SecuritySettings > securitySettings ,
2931 AppCaches appCaches ,
3032 ITwoFactorLoginService twoFactorLoginService )
3133 {
3234 _textService = textService ;
3335 _entityService = entityService ;
3436 _globalSettings = globalSettings . Value ;
37+ _securitySettings = securitySettings . Value ;
3538 _appCaches = appCaches ;
3639 _twoFactorLoginService = twoFactorLoginService ;
3740 }
3841
42+ [ Obsolete ( "Use constructor that also takes an IOptions<SecuritySettings>. Scheduled for removal in V14" ) ]
43+ public IdentityMapDefinition (
44+ ILocalizedTextService textService ,
45+ IEntityService entityService ,
46+ IOptions < GlobalSettings > globalSettings ,
47+ AppCaches appCaches ,
48+ ITwoFactorLoginService twoFactorLoginService )
49+ : this (
50+ textService ,
51+ entityService ,
52+ globalSettings ,
53+ StaticServiceProvider . Instance . GetRequiredService < IOptions < SecuritySettings > > ( ) ,
54+ appCaches ,
55+ twoFactorLoginService )
56+ {
57+ }
58+
3959 [ Obsolete ( "Use constructor that also takes an ITwoFactorLoginService. Scheduled for removal in V12" ) ]
4060 public IdentityMapDefinition (
4161 ILocalizedTextService textService ,
4262 IEntityService entityService ,
4363 IOptions < GlobalSettings > globalSettings ,
4464 AppCaches appCaches )
4565 : this (
46- textService ,
47- entityService ,
48- globalSettings ,
49- appCaches ,
50- StaticServiceProvider . Instance . GetRequiredService < ITwoFactorLoginService > ( ) )
66+ textService ,
67+ entityService ,
68+ globalSettings ,
69+ StaticServiceProvider . Instance . GetRequiredService < IOptions < SecuritySettings > > ( ) ,
70+ appCaches ,
71+ StaticServiceProvider . Instance . GetRequiredService < ITwoFactorLoginService > ( ) )
5172 {
5273 }
5374
@@ -107,7 +128,8 @@ private void Map(IUser source, BackOfficeIdentityUser target)
107128 source . GetUserCulture ( _textService , _globalSettings ) . ToString ( ) ; // project CultureInfo to string
108129 target . IsApproved = source . IsApproved ;
109130 target . SecurityStamp = source . SecurityStamp ;
110- target . LockoutEnd = source . IsLockedOut ? DateTime . MaxValue . ToUniversalTime ( ) : ( DateTime ? ) null ;
131+ DateTime ? lockedOutUntil = source . LastLockoutDate ? . AddMinutes ( _securitySettings . UserDefaultLockoutTimeInMinutes ) ;
132+ target . LockoutEnd = source . IsLockedOut ? ( lockedOutUntil ?? DateTime . MaxValue ) . ToUniversalTime ( ) : null ;
111133 }
112134
113135 // Umbraco.Code.MapAll -Id -LockoutEnabled -PhoneNumber -PhoneNumberConfirmed -ConcurrencyStamp -NormalizedEmail -NormalizedUserName -Roles
@@ -124,7 +146,8 @@ private void Map(IMember source, MemberIdentityUser target)
124146 target . PasswordConfig = source . PasswordConfiguration ;
125147 target . IsApproved = source . IsApproved ;
126148 target . SecurityStamp = source . SecurityStamp ;
127- target . LockoutEnd = source . IsLockedOut ? DateTime . MaxValue . ToUniversalTime ( ) : ( DateTime ? ) null ;
149+ DateTime ? lockedOutUntil = source . LastLockoutDate ? . AddMinutes ( _securitySettings . UserDefaultLockoutTimeInMinutes ) ;
150+ target . LockoutEnd = source . IsLockedOut ? ( lockedOutUntil ?? DateTime . MaxValue ) . ToUniversalTime ( ) : null ;
128151 target . Comments = source . Comments ;
129152 target . LastLockoutDateUtc = source . LastLockoutDate == DateTime . MinValue
130153 ? null
0 commit comments