diff --git a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs index b235d9358f..dbfa1ef92b 100644 --- a/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.OAuth/OAuthHandler.cs @@ -8,7 +8,6 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; using System.Text; -using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http.Authentication; diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index 65ad981a9c..452a15a9dc 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Net.Http; using System.Security.Cryptography; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; @@ -32,17 +31,18 @@ namespace Microsoft.AspNetCore.Authentication protected virtual async Task HandleRemoteCallbackAsync() { - AuthenticateResult authResult = null; + AuthenticationTicket ticket = null; Exception exception = null; try { - authResult = await HandleRemoteAuthenticateAsync(); + var authResult = await HandleRemoteAuthenticateAsync(); if (authResult != null && authResult.Skipped == true) { return false; } - else if (authResult == null) + + if (authResult == null) { exception = new InvalidOperationException("Invalid return state, unable to redirect."); } @@ -51,6 +51,8 @@ namespace Microsoft.AspNetCore.Authentication exception = authResult?.Failure ?? new InvalidOperationException("Invalid return state, unable to redirect."); } + + ticket = authResult.Ticket; } catch (Exception ex) { @@ -67,18 +69,16 @@ namespace Microsoft.AspNetCore.Authentication { return true; } - else if (errorContext.Skipped) + + if (errorContext.Skipped) { return false; } - else - { - throw new AggregateException("Unhandled remote failure.", exception); - } + + throw new AggregateException("Unhandled remote failure.", exception); } // We have a ticket if we get here - var ticket = authResult.Ticket; var context = new TicketReceivedContext(Context, Options, ticket) { ReturnUri = ticket.Properties.RedirectUri,