@@ -18,6 +18,7 @@ public class IdentityMapDefinition : IMapDefinition
18
18
{
19
19
private readonly AppCaches _appCaches ;
20
20
private readonly IEntityService _entityService ;
21
+ private readonly SecuritySettings _securitySettings ;
21
22
private readonly GlobalSettings _globalSettings ;
22
23
private readonly ILocalizedTextService _textService ;
23
24
private readonly ITwoFactorLoginService _twoFactorLoginService ;
@@ -26,28 +27,48 @@ public IdentityMapDefinition(
26
27
ILocalizedTextService textService ,
27
28
IEntityService entityService ,
28
29
IOptions < GlobalSettings > globalSettings ,
30
+ IOptions < SecuritySettings > securitySettings ,
29
31
AppCaches appCaches ,
30
32
ITwoFactorLoginService twoFactorLoginService )
31
33
{
32
34
_textService = textService ;
33
35
_entityService = entityService ;
34
36
_globalSettings = globalSettings . Value ;
37
+ _securitySettings = securitySettings . Value ;
35
38
_appCaches = appCaches ;
36
39
_twoFactorLoginService = twoFactorLoginService ;
37
40
}
38
41
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
+
39
59
[ Obsolete ( "Use constructor that also takes an ITwoFactorLoginService. Scheduled for removal in V12" ) ]
40
60
public IdentityMapDefinition (
41
61
ILocalizedTextService textService ,
42
62
IEntityService entityService ,
43
63
IOptions < GlobalSettings > globalSettings ,
44
64
AppCaches appCaches )
45
65
: 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 > ( ) )
51
72
{
52
73
}
53
74
@@ -107,7 +128,8 @@ private void Map(IUser source, BackOfficeIdentityUser target)
107
128
source . GetUserCulture ( _textService , _globalSettings ) . ToString ( ) ; // project CultureInfo to string
108
129
target . IsApproved = source . IsApproved ;
109
130
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 ;
111
133
}
112
134
113
135
// Umbraco.Code.MapAll -Id -LockoutEnabled -PhoneNumber -PhoneNumberConfirmed -ConcurrencyStamp -NormalizedEmail -NormalizedUserName -Roles
@@ -124,7 +146,8 @@ private void Map(IMember source, MemberIdentityUser target)
124
146
target . PasswordConfig = source . PasswordConfiguration ;
125
147
target . IsApproved = source . IsApproved ;
126
148
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 ;
128
151
target . Comments = source . Comments ;
129
152
target . LastLockoutDateUtc = source . LastLockoutDate == DateTime . MinValue
130
153
? null
0 commit comments