From 241880eadc0216918b1f879b403567ff6cb4d03c Mon Sep 17 00:00:00 2001 From: agoretsky Date: Tue, 19 Sep 2017 19:14:49 +0300 Subject: [PATCH] Minor improvements (#1403) * Fixed exception overwriting due to possible NullReferenceException * Removed unused local variables --- .../CookieAuthenticationHandler.cs | 5 ++--- .../RemoteAuthenticationHandler.cs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs index 996c334a73..754c91f1e8 100644 --- a/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationHandler.cs @@ -132,7 +132,6 @@ namespace Microsoft.AspNetCore.Authentication.Cookies } var currentUtc = Clock.UtcNow; - var issuedUtc = ticket.Properties.IssuedUtc; var expiresUtc = ticket.Properties.ExpiresUtc; if (expiresUtc != null && expiresUtc.Value < currentUtc) @@ -246,7 +245,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies _signInCalled = true; // Process the request cookie to initialize members like _sessionKey. - var result = await EnsureCookieTicket(); + await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); var signInContext = new CookieSigningInContext( @@ -328,7 +327,7 @@ namespace Microsoft.AspNetCore.Authentication.Cookies _signOutCalled = true; // Process the request cookie to initialize members like _sessionKey. - var ticket = await EnsureCookieTicket(); + await EnsureCookieTicket(); var cookieOptions = BuildCookieOptions(); if (Options.SessionStore != null && _sessionKey != null) { diff --git a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs index bcd5983642..1134566d88 100644 --- a/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs +++ b/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs @@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Authentication new InvalidOperationException("Invalid return state, unable to redirect."); } - ticket = authResult.Ticket; + ticket = authResult?.Ticket; } catch (Exception ex) {