@@ -132,12 +132,17 @@ public AuthenticationController(
132132 AuthorizationPolicies . BackOfficeAccess ) ] // Needed to enforce the principle set on the request, if one exists.
133133 public IDictionary < string , object > GetPasswordConfig ( int userId )
134134 {
135+ if ( HttpContext . HasActivePasswordResetFlowSession ( userId ) )
136+ {
137+ return _passwordConfiguration . GetConfiguration ( ) ;
138+ }
139+
135140 Attempt < int > currentUserId =
136141 _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 > ( ) ;
141146 }
142147
143148 /// <summary>
@@ -345,6 +350,8 @@ public async Task<bool> IsAuthenticated()
345350 [ Authorize ( Policy = AuthorizationPolicies . DenyLocalLoginIfConfigured ) ]
346351 public async Task < ActionResult < UserDetail ? > > PostLogin ( LoginModel loginModel )
347352 {
353+ HttpContext . EndPasswordResetFlowSession ( ) ;
354+
348355 // Start a timed scope to ensure failed responses return is a consistent time
349356 await using var timedScope = new TimedScope ( GetLoginDuration ( ) , CancellationToken . None ) ;
350357
@@ -440,6 +447,8 @@ public async Task<IActionResult> PostRequestPasswordReset(RequestPasswordResetMo
440447 return BadRequest ( ) ;
441448 }
442449
450+ HttpContext . EndPasswordResetFlowSession ( ) ;
451+
443452 BackOfficeIdentityUser ? identityUser = await _userManager . FindByEmailAsync ( model . Email ) ;
444453
445454 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)
593602 [ AllowAnonymous ]
594603 public async Task < IActionResult > PostSetPassword ( SetPasswordModel model )
595604 {
605+ HttpContext . EndPasswordResetFlowSession ( ) ;
606+
596607 BackOfficeIdentityUser ? identityUser =
597608 await _userManager . FindByIdAsync ( model . UserId . ToString ( CultureInfo . InvariantCulture ) ) ;
598609
0 commit comments