From 45900c90b125de1a7e54579777539bcbcb75692b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:29:20 +0000 Subject: [PATCH 1/4] Initial plan From 6bd9dbb226907e4d60d85070fbffc7c5e314b853 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:50:29 +0000 Subject: [PATCH 2/4] Update RefreshSignInAsync documentation and fix null checks - Updated XML documentation to clearly state user must be signed in - Added explicit null check for auth result at the beginning - Removed unnecessary null-conditional operators after auth.Succeeded check - All existing tests pass Co-authored-by: halter73 <54385+halter73@users.noreply.github.com> --- src/Identity/Core/src/SignInManager.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Identity/Core/src/SignInManager.cs b/src/Identity/Core/src/SignInManager.cs index 4d139a408828..a1f8dfad78a5 100644 --- a/src/Identity/Core/src/SignInManager.cs +++ b/src/Identity/Core/src/SignInManager.cs @@ -165,10 +165,14 @@ public virtual async Task CanSignInAsync(TUser user) } /// - /// Signs in the specified , whilst preserving the existing + /// Refreshes the sign-in for the specified , whilst preserving the existing /// AuthenticationProperties of the current signed-in user like rememberMe, as an asynchronous operation. /// - /// The user to sign-in. + /// + /// The user must already be signed in, and the user ID must match the currently authenticated user. + /// If the user is not signed in, use instead. + /// + /// The user to refresh the sign-in for. /// The task object representing the asynchronous operation. public virtual async Task RefreshSignInAsync(TUser user) { @@ -189,6 +193,12 @@ public virtual async Task RefreshSignInAsync(TUser user) private async Task<(bool success, bool? isPersistent)> RefreshSignInCoreAsync(TUser user) { var auth = await Context.AuthenticateAsync(AuthenticationScheme); + if (auth == null) + { + Logger.LogError("RefreshSignInAsync prevented because authentication result is null."); + return (false, null); + } + if (!auth.Succeeded || auth.Principal?.Identity?.IsAuthenticated != true) { Logger.LogError("RefreshSignInAsync prevented because the user is not currently authenticated. Use SignInAsync instead for initial sign in."); @@ -204,8 +214,8 @@ public virtual async Task RefreshSignInAsync(TUser user) } IList claims = Array.Empty(); - var authenticationMethod = auth.Principal?.FindFirst(ClaimTypes.AuthenticationMethod); - var amr = auth.Principal?.FindFirst("amr"); + var authenticationMethod = auth.Principal.FindFirst(ClaimTypes.AuthenticationMethod); + var amr = auth.Principal.FindFirst("amr"); if (authenticationMethod != null || amr != null) { @@ -221,7 +231,7 @@ public virtual async Task RefreshSignInAsync(TUser user) } await SignInWithClaimsAsync(user, auth.Properties, claims); - return (true, auth.Properties?.IsPersistent ?? false); + return (true, auth.Properties.IsPersistent); } /// From 8c94c54696889e19d90cf48ff9c798a420fb35a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:54:18 +0000 Subject: [PATCH 3/4] Remove unnecessary null check for auth result AuthenticateAsync guarantees to return non-null result, so the explicit null check is not needed. The code now only removes unnecessary null- conditional operators after confirming auth.Succeeded is true. Co-authored-by: halter73 <54385+halter73@users.noreply.github.com> --- src/Identity/Core/src/SignInManager.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Identity/Core/src/SignInManager.cs b/src/Identity/Core/src/SignInManager.cs index a1f8dfad78a5..79f87e772003 100644 --- a/src/Identity/Core/src/SignInManager.cs +++ b/src/Identity/Core/src/SignInManager.cs @@ -193,12 +193,6 @@ public virtual async Task RefreshSignInAsync(TUser user) private async Task<(bool success, bool? isPersistent)> RefreshSignInCoreAsync(TUser user) { var auth = await Context.AuthenticateAsync(AuthenticationScheme); - if (auth == null) - { - Logger.LogError("RefreshSignInAsync prevented because authentication result is null."); - return (false, null); - } - if (!auth.Succeeded || auth.Principal?.Identity?.IsAuthenticated != true) { Logger.LogError("RefreshSignInAsync prevented because the user is not currently authenticated. Use SignInAsync instead for initial sign in."); From 6b5564808cd7d5242a17e4303c4e0ac3868f81b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:56:55 +0000 Subject: [PATCH 4/4] Fix XML documentation method reference Update method reference to include nullable parameter annotation (string?) Co-authored-by: halter73 <54385+halter73@users.noreply.github.com> --- src/Identity/Core/src/SignInManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Identity/Core/src/SignInManager.cs b/src/Identity/Core/src/SignInManager.cs index 79f87e772003..048f849c5a8a 100644 --- a/src/Identity/Core/src/SignInManager.cs +++ b/src/Identity/Core/src/SignInManager.cs @@ -170,7 +170,7 @@ public virtual async Task CanSignInAsync(TUser user) /// /// /// The user must already be signed in, and the user ID must match the currently authenticated user. - /// If the user is not signed in, use instead. + /// If the user is not signed in, use instead. /// /// The user to refresh the sign-in for. /// The task object representing the asynchronous operation.