Skip to content

Commit

Permalink
fix: Fixes bad password with SHA1/SHA2 (#1952)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Sep 13, 2024
1 parent 257825d commit 8639ed2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion Projects/Server/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ public static void RunEventLoop()

// Handle networking
NetState.Slice();
// PingServer.Slice();

// Execute captured post-await methods (like Timer.Pause)
LoopContext.ExecuteTasks();
Expand Down
8 changes: 6 additions & 2 deletions Projects/UOContent/Accounting/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,17 @@ public void Delete()

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;

Expand Down

0 comments on commit 8639ed2

Please sign in to comment.