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

Last change on this file since 326 was 325, checked in by alloc, 6 years ago

Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)

File size: 1.1 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 {
[325]7 public UserStatusHandler (string moduleName = null) : base (moduleName) {
[244]8 }
9
[325]10 public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user,
11 int permissionLevel) {
[244]12 JSONObject result = new JSONObject ();
13
14 result.Add ("loggedin", new JSONBoolean (user != null));
15 result.Add ("username", new JSONString (user != null ? user.SteamID.ToString () : string.Empty));
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));
[325]21 permObj.Add ("allowed",
22 new JSONBoolean (WebPermissions.Instance.ModuleAllowedWithLevel (perm.module, permissionLevel)));
[244]23 perms.Add (permObj);
24 }
[325]25
[244]26 result.Add ("permissions", perms);
27
[325]28 WebAPI.WriteJSON (resp, result);
[244]29 }
30 }
[325]31}
Note: See TracBrowser for help on using the repository browser.