Removed error constructor. Added response property.
This commit is contained in:
parent
89f5d13efb
commit
a0da52e558
3 changed files with 10 additions and 10 deletions
|
|
@ -154,16 +154,16 @@ namespace TShockAPI
|
|||
get { return SafeGet("error"); }
|
||||
set { SafeSet("error", value); }
|
||||
}
|
||||
public string Response
|
||||
{
|
||||
get { return SafeGet("response"); }
|
||||
set { SafeSet("response", value); }
|
||||
}
|
||||
|
||||
public RestObject(string status)
|
||||
{
|
||||
Status = status;
|
||||
}
|
||||
public RestObject(string status, string error)
|
||||
: this(status)
|
||||
{
|
||||
Error = error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets value safely.
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace TShockAPI
|
|||
obj = Verify(user, pass);
|
||||
|
||||
if (obj == null)
|
||||
obj = new RestObject("401", "Invalid username/password combination provided. Please re-submit your query with a correct pair.");
|
||||
obj = new RestObject("401") { Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair." };
|
||||
|
||||
if (obj.Error != null)
|
||||
return obj;
|
||||
|
|
|
|||
|
|
@ -222,20 +222,20 @@ namespace TShockAPI
|
|||
var userAccount = TShock.Users.GetUserByName(username);
|
||||
if (userAccount == null)
|
||||
{
|
||||
return new RestObject("401", "Invalid username/password combination provided. Please re-submit your query with a correct pair.");
|
||||
return new RestObject("401") { Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair." };
|
||||
}
|
||||
|
||||
if (Tools.HashPassword(password).ToUpper() != userAccount.Password.ToUpper())
|
||||
{
|
||||
return new RestObject("401", "Invalid username/password combination provided. Please re-submit your query with a correct pair.");
|
||||
return new RestObject("401") { Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair." };
|
||||
}
|
||||
|
||||
if (!Tools.GetGroup(userAccount.Group).HasPermission("api") && userAccount.Group != "superadmin")
|
||||
{
|
||||
return new RestObject("403", "Although your account was successfully found and identified, your account lacks the permission required to use the API. (api)");
|
||||
return new RestObject("403") { Error = "Although your account was successfully found and identified, your account lacks the permission required to use the API. (api)" };
|
||||
}
|
||||
|
||||
return new RestObject("200"); //Maybe return some user info too?
|
||||
return new RestObject("200") { Response = "Successful login" }; //Maybe return some user info too?
|
||||
}
|
||||
|
||||
public override void DeInitialize()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue