-Added REST endpoint "/v2/token/destroy/all"
-Added command "/rest destroytokens", "/rest listusers"
This commit is contained in:
parent
d9ff9a6ac5
commit
4d95b5594e
3 changed files with 66 additions and 2 deletions
|
|
@ -26,6 +26,9 @@ namespace Rests
|
|||
[Description("User can create REST tokens.")]
|
||||
public static readonly string restapi;
|
||||
|
||||
[Description("User or REST user can destroy all REST tokens.")]
|
||||
public static readonly string restmanage;
|
||||
|
||||
|
||||
[Description("REST user can turn off / restart the server.")]
|
||||
public static readonly string restmaintenance;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ namespace Rests
|
|||
Register(new RestCommand("/token/create/{username}/{password}", NewToken) { DoLog = false });
|
||||
Register(new RestCommand("/v2/token/create/{password}", NewTokenV2) { DoLog = false });
|
||||
Register(new SecureRestCommand("/token/destroy/{token}", DestroyToken));
|
||||
Register(new SecureRestCommand("/v2/token/destroy/all", DestroyAllTokens, RestPermissions.restmanage));
|
||||
|
||||
foreach (KeyValuePair<string, TokenData> t in TShockAPI.TShock.RESTStartupTokens)
|
||||
{
|
||||
|
|
@ -67,6 +68,14 @@ namespace Rests
|
|||
}
|
||||
return new Dictionary<string, string>
|
||||
{{"status", "200"}, {"response", "Requested token was successfully destroyed."}};
|
||||
}
|
||||
|
||||
private object DestroyAllTokens(RestVerbs verbs, IParameterCollection parameters, SecureRest.TokenData tokenData)
|
||||
{
|
||||
Tokens.Clear();
|
||||
|
||||
return new Dictionary<string, string>
|
||||
{{"status", "200"}, {"response", "All tokens were successfully destroyed."}};
|
||||
}
|
||||
|
||||
private object NewTokenV2(RestVerbs verbs, IParameterCollection parameters)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue