Fixed so name searching only returns the last account logged in with that name.

This commit is contained in:
Jonathan Williams 2015-05-06 20:19:58 -07:00
parent a7407d8b8c
commit d3e5dd9c8a
2 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -59,10 +59,17 @@
public List<String> GetAllAccountNamesMatching(string name)
{
var accounts = new List<String>();
using (var repository = _repositoryFactory.CreateRepository())
{
return repository.GetAll<Account>().Where(c => c.Name == name).Select(y => y.Name).ToList();
var account = repository.Where<Account>(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<Account>(x => x.Name == name).FirstOrDefault();
var account = repository.Where<Account>(x => x.Name == name).OrderByDescending(y => y.LastLogin).FirstOrDefault();
account.LoadNavigationProperties(repository.Context);
return account;