Rest api now has a permission, Permissions.restapi. However, the string attached to the permission is "api" for backwards compatability. We should give server owners and plugin devs a notice and change it to "restapi" in a few days/weeks.
This commit is contained in:
parent
f672f50783
commit
a91949a60a
2 changed files with 7 additions and 1 deletions
|
|
@ -164,12 +164,18 @@ namespace TShockAPI
|
||||||
[Description("User can save all the players SSI state.")]
|
[Description("User can save all the players SSI state.")]
|
||||||
public static readonly string savessi;
|
public static readonly string savessi;
|
||||||
|
|
||||||
|
[Description("User can use rest api calls.")]
|
||||||
|
public static readonly string restapi;
|
||||||
|
|
||||||
static Permissions()
|
static Permissions()
|
||||||
{
|
{
|
||||||
foreach (var field in typeof (Permissions).GetFields())
|
foreach (var field in typeof (Permissions).GetFields())
|
||||||
{
|
{
|
||||||
field.SetValue(null, field.Name);
|
field.SetValue(null, field.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Backwards compatability.
|
||||||
|
restapi = "api";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Command> GetCommands(string perm)
|
private static List<Command> GetCommands(string perm)
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ namespace TShockAPI
|
||||||
{Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."};
|
{Error = "Invalid username/password combination provided. Please re-submit your query with a correct pair."};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Utils.GetGroup(userAccount.Group).HasPermission("api") && userAccount.Group != "superadmin")
|
if (!Utils.GetGroup(userAccount.Group).HasPermission(Permissions.restapi) && userAccount.Group != "superadmin")
|
||||||
{
|
{
|
||||||
return new RestObject("403")
|
return new RestObject("403")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue