source: binary-improvements/MapRendering/Web/Handlers/UserStatusHandler.cs@ 412

Last change on this file since 412 was 369, checked in by alloc, 3 years ago

Preparations for A20 release
Changes usage of "SteamID" to "UserID" in console commands
Also changes a bunch of the WebAPI stuff to show / use UserIDs

File size: 1.0 KB
RevLine 
[244]1using System.Net;
2using AllocsFixes.JSON;
[325]3using AllocsFixes.NetConnections.Servers.Web.API;
[244]4
[325]5namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
[244]6 public class UserStatusHandler : PathHandler {
[351]7 public UserStatusHandler (string _moduleName = null) : base (_moduleName) {
[244]8 }
9
[351]10 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
11 int _permissionLevel) {
[244]12 JSONObject result = new JSONObject ();
13
[351]14 result.Add ("loggedin", new JSONBoolean (_user != null));
[369]15 result.Add ("username", new JSONString (_user != null ? _user.UserId.ToString () : string.Empty));
[244]16
17 JSONArray perms = new JSONArray ();
18 foreach (WebPermissions.WebModulePermission perm in WebPermissions.Instance.GetModules ()) {
19 JSONObject permObj = new JSONObject ();
20 permObj.Add ("module", new JSONString (perm.module));
[351]21 permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _permissionLevel));
[244]22 perms.Add (permObj);
23 }
[325]24
[244]25 result.Add ("permissions", perms);
26
[351]27 WebAPI.WriteJSON (_resp, result);
[244]28 }
29 }
[325]30}
Note: See TracBrowser for help on using the repository browser.