From 8639ed22107f4fe58c44a760412bef0b0d9a219f Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:20:44 -0700 Subject: [PATCH] fix: Fixes bad password with SHA1/SHA2 (#1952) --- Projects/Server/Main.cs | 1 - Projects/UOContent/Accounting/Account.cs | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index a292f94bf..79fa61788 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -463,7 +463,6 @@ public static class Core // Handle networking NetState.Slice(); - // PingServer.Slice(); // Execute captured post-await methods (like Timer.Pause) LoopContext.ExecuteTasks(); diff --git a/Projects/UOContent/Accounting/Account.cs b/Projects/UOContent/Accounting/Account.cs index 46c2b0071..f4ecb2723 100644 --- a/Projects/UOContent/Accounting/Account.cs +++ b/Projects/UOContent/Accounting/Account.cs @@ -362,13 +362,17 @@ public partial class Account : IAccount, IComparable public void SetPassword(string plainPassword) { - Password = AccountSecurity.CurrentPasswordProtection.EncryptPassword(plainPassword); + var phrase = _passwordAlgorithm is PasswordProtectionAlgorithm.SHA1 or PasswordProtectionAlgorithm.SHA2 + ? $"{_username}{plainPassword}" + : plainPassword; + + Password = AccountSecurity.CurrentPasswordProtection.EncryptPassword(phrase); PasswordAlgorithm = AccountSecurity.CurrentAlgorithm; } public bool CheckPassword(string plainPassword) { - var phrase = _passwordAlgorithm == PasswordProtectionAlgorithm.SHA1 + var phrase = _passwordAlgorithm is PasswordProtectionAlgorithm.SHA1 or PasswordProtectionAlgorithm.SHA2 ? $"{_username}{plainPassword}" : plainPassword;