@@ -327,7 +327,6 @@ protected virtual Task HandleSignOutAsync(SignOutContext context)
327
327
/// Override this method to deal with a challenge that is forbidden.
328
328
/// </summary>
329
329
/// <param name="context"></param>
330
- /// <returns>The returned boolean is ignored.</returns>
331
330
protected virtual Task < bool > HandleForbiddenAsync ( ChallengeContext context )
332
331
{
333
332
Response . StatusCode = 403 ;
@@ -340,7 +339,7 @@ protected virtual Task<bool> HandleForbiddenAsync(ChallengeContext context)
340
339
/// changing the 401 result to 302 of a login page or external sign-in location.)
341
340
/// </summary>
342
341
/// <param name="context"></param>
343
- /// <returns>The returned boolean is no longer used. </returns>
342
+ /// <returns>True if no other handlers should be called </returns>
344
343
protected virtual Task < bool > HandleUnauthorizedAsync ( ChallengeContext context )
345
344
{
346
345
Response . StatusCode = 401 ;
@@ -350,6 +349,7 @@ protected virtual Task<bool> HandleUnauthorizedAsync(ChallengeContext context)
350
349
public async Task ChallengeAsync ( ChallengeContext context )
351
350
{
352
351
ChallengeCalled = true ;
352
+ var handled = false ;
353
353
if ( ShouldHandleScheme ( context . AuthenticationScheme , Options . AutomaticChallenge ) )
354
354
{
355
355
switch ( context . Behavior )
@@ -363,18 +363,18 @@ public async Task ChallengeAsync(ChallengeContext context)
363
363
}
364
364
goto case ChallengeBehavior . Unauthorized ;
365
365
case ChallengeBehavior . Unauthorized :
366
- await HandleUnauthorizedAsync ( context ) ;
366
+ handled = await HandleUnauthorizedAsync ( context ) ;
367
367
Logger . AuthenticationSchemeChallenged ( Options . AuthenticationScheme ) ;
368
368
break ;
369
369
case ChallengeBehavior . Forbidden :
370
- await HandleForbiddenAsync ( context ) ;
370
+ handled = await HandleForbiddenAsync ( context ) ;
371
371
Logger . AuthenticationSchemeForbidden ( Options . AuthenticationScheme ) ;
372
372
break ;
373
373
}
374
374
context . Accept ( ) ;
375
375
}
376
376
377
- if ( PriorHandler != null )
377
+ if ( ! handled && PriorHandler != null )
378
378
{
379
379
await PriorHandler . ChallengeAsync ( context ) ;
380
380
}
0 commit comments