From 84789ff4d5c162e3c92205f82acb7c26a94abf42 Mon Sep 17 00:00:00 2001 From: stevenh Date: Mon, 20 Feb 2012 21:44:25 +0000 Subject: [PATCH] Fixed GetUser not locating users by ID and hence GetUserById not working either, fixes #395 --- TShockAPI/DB/UserManager.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index afb0d8dc..7aa6a0d3 100644 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -257,14 +257,12 @@ namespace TShockAPI.DB try { 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); - } else - { result = database.QueryReader("SELECT * FROM Users WHERE IP=@0", user.Address); - } if (result.Read()) { @@ -273,7 +271,9 @@ namespace TShockAPI.DB if (!result.Read()) 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)); else throw new UserManagerException(String.Format("Multiple users found for ip '{0}'", user.Address));