From 3d307c659f582cf75d4c2534de468008211f7bf3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 May 2025 11:54:17 +0000 Subject: [PATCH 1/3] Initial plan for issue From f451f2dc54d1d92579d211670948fadfa826b953 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 May 2025 11:59:02 +0000 Subject: [PATCH 2/3] Add try-catch for password reset operations Co-authored-by: davidjrh <489976+davidjrh@users.noreply.github.com> --- .../Components/AzureClient.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DotNetNuke.Authentication.Azure/Components/AzureClient.cs b/DotNetNuke.Authentication.Azure/Components/AzureClient.cs index fa9c71e..5ce12ef 100644 --- a/DotNetNuke.Authentication.Azure/Components/AzureClient.cs +++ b/DotNetNuke.Authentication.Azure/Components/AzureClient.cs @@ -741,7 +741,15 @@ private void UpdateUserAndRoles(UserInfo userInfo) { // Reset user password with a new one to avoid password expiration errors on DNN for Azure AD users MembershipUser aspnetUser = Membership.GetUser(userInfo.Username); - aspnetUser.ResetPassword(); + try + { + aspnetUser.ResetPassword(); + } + catch (Exception ex) + { + // If password reset is disabled, log the error but continue with the authentication process + Logger.Warn("Unable to reset password, continuing with login: " + ex.Message); + } // Last login date not being updated by DNN on OAuth login, so we have to do it manually aspnetUser = Membership.GetUser(userInfo.Username); From 1f7215c919510664eb6b6e44c51e05f00421bcf0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 May 2025 13:15:08 +0000 Subject: [PATCH 3/3] Check EnablePasswordReset property instead of using try/catch Co-authored-by: davidjrh <489976+davidjrh@users.noreply.github.com> --- DotNetNuke.Authentication.Azure/Components/AzureClient.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/DotNetNuke.Authentication.Azure/Components/AzureClient.cs b/DotNetNuke.Authentication.Azure/Components/AzureClient.cs index 5ce12ef..e7faf7d 100644 --- a/DotNetNuke.Authentication.Azure/Components/AzureClient.cs +++ b/DotNetNuke.Authentication.Azure/Components/AzureClient.cs @@ -741,15 +741,10 @@ private void UpdateUserAndRoles(UserInfo userInfo) { // Reset user password with a new one to avoid password expiration errors on DNN for Azure AD users MembershipUser aspnetUser = Membership.GetUser(userInfo.Username); - try + if (Membership.Provider.EnablePasswordReset) { aspnetUser.ResetPassword(); } - catch (Exception ex) - { - // If password reset is disabled, log the error but continue with the authentication process - Logger.Warn("Unable to reset password, continuing with login: " + ex.Message); - } // Last login date not being updated by DNN on OAuth login, so we have to do it manually aspnetUser = Membership.GetUser(userInfo.Username);