fix: Fixes looking up accounts that were renamed. (#2078)

This commit is contained in:
Kamron Batman 2025-01-18 17:11:43 -08:00 committed by GitHub
parent d92b735c18
commit b4b7182ce6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View file

@ -21,7 +21,7 @@ public partial class Account : IAccount, IComparable<Account>
public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays(30.0);
[InternString]
[SerializableField(0)]
[SerializableField(0, setter: "private")]
private string _username;
[SerializableField(1)]
@ -365,6 +365,19 @@ public partial class Account : IAccount, IComparable<Account>
public bool Deleted { get; private set; }
public bool TrySetUsername(string username)
{
if (username == _username || Accounts.GetAccount(username) != null)
{
return false;
}
Accounts.Remove(this);
Username = username;
Accounts.Add(this);
return true;
}
public void SetPassword(string plainPassword)
{
var phrase = _passwordAlgorithm is PasswordProtectionAlgorithm.SHA1 or PasswordProtectionAlgorithm.SHA2