Changed to use a separate account for each email address.

This commit is contained in:
Kei-Luna
2026-05-13 08:15:33 +09:00
parent 5332d5fe1a
commit 41df375e21
7 changed files with 146 additions and 19 deletions

View File

@@ -26,11 +26,14 @@ public class AccountData : BaseDatabaseDataHelper
AccountData? result = null;
DatabaseHelper.GetAllInstance<AccountData>()?.ForEach(account =>
{
if (account.Username == username) result = account;
if (string.Equals(account.Username, username, StringComparison.OrdinalIgnoreCase)) result = account;
});
return result;
}
public static AccountData? GetAccountByEmail(string email)
=> GetAccountByUserName(email);
public static AccountData? GetAccountByUid(int uid, bool force = false)
{
var result = DatabaseHelper.GetInstance<AccountData>(uid, force);
@@ -61,8 +64,15 @@ public class AccountData : BaseDatabaseDataHelper
#region Account
public static void CreateAccount(string username, int uid, string password)
public static AccountData CreateAccount(string username, int uid, string password)
{
if (string.IsNullOrWhiteSpace(username))
throw new ArgumentException("Username cannot be empty.", nameof(username));
if (GetAccountByUserName(username) != null)
throw new InvalidOperationException($"Account '{username}' already exists.");
if (uid != 0 && GetAccountByUid(uid) != null)
throw new InvalidOperationException($"UID '{uid}' is already in use.");
var newUid = uid;
if (uid == 0)
{
@@ -84,6 +94,7 @@ public class AccountData : BaseDatabaseDataHelper
SetPassword(account, password);
DatabaseHelper.CreateInstance(account);
return account;
}
public static void DeleteAccount(int uid)
@@ -178,4 +189,4 @@ public class AccountData : BaseDatabaseDataHelper
}
#endregion
}
}