@@ -132,12 +132,17 @@ public AuthenticationController(
132
132
AuthorizationPolicies . BackOfficeAccess ) ] // Needed to enforce the principle set on the request, if one exists.
133
133
public IDictionary < string , object > GetPasswordConfig ( int userId )
134
134
{
135
+ if ( HttpContext . HasActivePasswordResetFlowSession ( userId ) )
136
+ {
137
+ return _passwordConfiguration . GetConfiguration ( ) ;
138
+ }
139
+
135
140
Attempt < int > currentUserId =
136
141
_backofficeSecurityAccessor . BackOfficeSecurity ? . GetUserId ( ) ?? Attempt < int > . Fail ( ) ;
137
- return _passwordConfiguration . GetConfiguration (
138
- currentUserId . Success
139
- ? currentUserId . Result != userId
140
- : true ) ;
142
+
143
+ return currentUserId . Success
144
+ ? _passwordConfiguration . GetConfiguration ( currentUserId . Result != userId )
145
+ : new Dictionary < string , object > ( ) ;
141
146
}
142
147
143
148
/// <summary>
@@ -345,6 +350,8 @@ public async Task<bool> IsAuthenticated()
345
350
[ Authorize ( Policy = AuthorizationPolicies . DenyLocalLoginIfConfigured ) ]
346
351
public async Task < ActionResult < UserDetail ? > > PostLogin ( LoginModel loginModel )
347
352
{
353
+ HttpContext . EndPasswordResetFlowSession ( ) ;
354
+
348
355
// Start a timed scope to ensure failed responses return is a consistent time
349
356
await using var timedScope = new TimedScope ( GetLoginDuration ( ) , CancellationToken . None ) ;
350
357
@@ -440,6 +447,8 @@ public async Task<IActionResult> PostRequestPasswordReset(RequestPasswordResetMo
440
447
return BadRequest ( ) ;
441
448
}
442
449
450
+ HttpContext . EndPasswordResetFlowSession ( ) ;
451
+
443
452
BackOfficeIdentityUser ? identityUser = await _userManager . FindByEmailAsync ( model . Email ) ;
444
453
445
454
await Task . Delay ( RandomNumberGenerator . GetInt32 ( 400 , 2500 ) ) ; // To randomize response time preventing user enumeration
@@ -593,6 +602,8 @@ public async Task<IActionResult> PostSend2FACode([FromBody] string provider)
593
602
[ AllowAnonymous ]
594
603
public async Task < IActionResult > PostSetPassword ( SetPasswordModel model )
595
604
{
605
+ HttpContext . EndPasswordResetFlowSession ( ) ;
606
+
596
607
BackOfficeIdentityUser ? identityUser =
597
608
await _userManager . FindByIdAsync ( model . UserId . ToString ( CultureInfo . InvariantCulture ) ) ;
598
609
0 commit comments