REST: Really shitty protection from nulls due to all parameters being optional in some cases. But it works, until someone can clean it up and i learn how to know better.

This commit is contained in:
Graham Cantin 2011-09-05 06:24:07 -07:00
parent afff00b502
commit 11a3ed7647

View file

@ -170,9 +170,34 @@ namespace TShockAPI {
object BanCreate(RestVerbs verbs, IParameterCollection parameters)
{
var returnBlock = new Dictionary<string, string>();
var ip = parameters["ip"];
var name = parameters["name"];
var reason = parameters["reason"];
if (ip == null && name == null)
{
returnBlock.Add("Error", "Required parameter missing.");
return returnBlock;
}
if (ip == null)
{
ip = "";
}
if (name == null)
{
name = "";
}
if (reason == null)
{
reason = "";
}
try
{
TShock.Bans.AddBan(parameters["ip"], parameters["name"], parameters["reason"]);
TShock.Bans.AddBan(ip, name, reason);
}
catch (Exception)
{