diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index 5d45845fe..b2fbd8368 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -38,7 +38,7 @@ public class AccountRepository extends RepositoryBase private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;"; private static String UPDATE_ACCOUNT_NULL_RANK = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=?, rankExpire=? WHERE uuid = ? AND rank IS NULL;"; - private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ?;"; + private static String SELECT_ACCOUNT_UUID_BY_NAME = "SELECT uuid FROM accounts WHERE name = ? ORDER BY lastLogin DESC;"; private String _webAddress; diff --git a/Website/LOC.Website.Common/Models/AccountAdministrator.cs b/Website/LOC.Website.Common/Models/AccountAdministrator.cs index 2fcca62f9..b205de2ef 100644 --- a/Website/LOC.Website.Common/Models/AccountAdministrator.cs +++ b/Website/LOC.Website.Common/Models/AccountAdministrator.cs @@ -59,10 +59,17 @@ public List GetAllAccountNamesMatching(string name) { + var accounts = new List(); + using (var repository = _repositoryFactory.CreateRepository()) { - return repository.GetAll().Where(c => c.Name == name).Select(y => y.Name).ToList(); + var account = repository.Where(x => x.Name == name).OrderByDescending(y => y.LastLogin).FirstOrDefault(); + + if (account != null) + accounts.Add(account.Name); } + + return accounts; } private object getAccountLock(string name) @@ -801,7 +808,7 @@ protected Account GetAccountByName(string name, IRepository repository) { - var account = repository.Where(x => x.Name == name).FirstOrDefault(); + var account = repository.Where(x => x.Name == name).OrderByDescending(y => y.LastLogin).FirstOrDefault(); account.LoadNavigationProperties(repository.Context); return account;