diff --git a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs index ea6803b49..8c9891946 100644 --- a/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OAuth/OAuthHandler.cs @@ -42,9 +42,10 @@ public override async Task InvokeAsync() public async Task InvokeReturnPathAsync() { var ticket = await HandleAuthenticateOnceAsync(); - if (ticket == null) + if (ticket?.Properties?.RedirectUri == null) { Logger.LogWarning("Invalid return state, unable to redirect."); + //Response.Redirect(Options.CallBackErrorPath); + some error Response.StatusCode = 500; return true; } @@ -63,7 +64,7 @@ public async Task InvokeReturnPathAsync() await Context.Authentication.SignInAsync(context.SignInScheme, context.Principal, context.Properties); } - if (!context.IsRequestCompleted && context.RedirectUri != null) + if (!context.IsRequestCompleted ) { if (context.Principal == null) { @@ -74,7 +75,7 @@ public async Task InvokeReturnPathAsync() context.RequestCompleted(); } - return context.IsRequestCompleted; + return true; } protected override async Task HandleAuthenticateAsync() @@ -89,8 +90,6 @@ protected override async Task HandleAuthenticateAsync() if (!StringValues.IsNullOrEmpty(value)) { Logger.LogVerbose("Remote server returned an error: " + Request.QueryString); - // TODO: Fail request rather than passing through? - return null; } var code = query["code"];