Merge pull request #396 from stevenh/general-devel
Fixed GetUser not locating users by ID
This commit is contained in:
commit
c774ef1229
1 changed files with 6 additions and 6 deletions
|
|
@ -257,14 +257,12 @@ namespace TShockAPI.DB
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
QueryResult result;
|
QueryResult result;
|
||||||
if (string.IsNullOrEmpty(user.Address))
|
if (0 != user.ID)
|
||||||
{
|
result = database.QueryReader("SELECT * FROM Users WHERE ID=@0", user.ID);
|
||||||
|
else if (string.IsNullOrEmpty(user.Address))
|
||||||
result = database.QueryReader("SELECT * FROM Users WHERE Username=@0", user.Name);
|
result = database.QueryReader("SELECT * FROM Users WHERE Username=@0", user.Name);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result = database.QueryReader("SELECT * FROM Users WHERE IP=@0", user.Address);
|
result = database.QueryReader("SELECT * FROM Users WHERE IP=@0", user.Address);
|
||||||
}
|
|
||||||
|
|
||||||
if (result.Read())
|
if (result.Read())
|
||||||
{
|
{
|
||||||
|
|
@ -273,7 +271,9 @@ namespace TShockAPI.DB
|
||||||
if (!result.Read())
|
if (!result.Read())
|
||||||
return user;
|
return user;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(user.Address))
|
if (0 != user.ID)
|
||||||
|
throw new UserManagerException(String.Format("Multiple users found for id '{0}'", user.ID));
|
||||||
|
else if (string.IsNullOrEmpty(user.Address))
|
||||||
throw new UserManagerException(String.Format("Multiple users found for name '{0}'", user.Name));
|
throw new UserManagerException(String.Format("Multiple users found for name '{0}'", user.Name));
|
||||||
else
|
else
|
||||||
throw new UserManagerException(String.Format("Multiple users found for ip '{0}'", user.Address));
|
throw new UserManagerException(String.Format("Multiple users found for ip '{0}'", user.Address));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue