| Rev | Line |  | 
|---|
| [244] | 1 | using System; | 
|---|
|  | 2 | using System.Collections.Generic; | 
|---|
|  | 3 | using System.IO; | 
|---|
|  | 4 | using System.Net; | 
|---|
|  | 5 | using System.Threading; | 
|---|
|  | 6 | using System.Text; | 
|---|
|  | 7 | using AllocsFixes.JSON; | 
|---|
|  | 8 |  | 
|---|
|  | 9 | namespace AllocsFixes.NetConnections.Servers.Web.Handlers | 
|---|
|  | 10 | { | 
|---|
|  | 11 | public class UserStatusHandler : PathHandler { | 
|---|
|  | 12 | public UserStatusHandler (string moduleName = null) : base(moduleName) { | 
|---|
|  | 13 | } | 
|---|
|  | 14 |  | 
|---|
|  | 15 | public override void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) { | 
|---|
|  | 16 | JSONObject result = new JSONObject (); | 
|---|
|  | 17 |  | 
|---|
|  | 18 | result.Add ("loggedin", new JSONBoolean (user != null)); | 
|---|
|  | 19 | result.Add ("username", new JSONString (user != null ? user.SteamID.ToString () : string.Empty)); | 
|---|
|  | 20 |  | 
|---|
|  | 21 | JSONArray perms = new JSONArray (); | 
|---|
|  | 22 | foreach (WebPermissions.WebModulePermission perm in WebPermissions.Instance.GetModules ()) { | 
|---|
|  | 23 | JSONObject permObj = new JSONObject (); | 
|---|
|  | 24 | permObj.Add ("module", new JSONString (perm.module)); | 
|---|
|  | 25 | permObj.Add ("allowed", new JSONBoolean (WebPermissions.Instance.ModuleAllowedWithLevel (perm.module, permissionLevel))); | 
|---|
|  | 26 | perms.Add (permObj); | 
|---|
|  | 27 | } | 
|---|
|  | 28 | result.Add ("permissions", perms); | 
|---|
|  | 29 |  | 
|---|
| [309] | 30 | AllocsFixes.NetConnections.Servers.Web.API.WebAPI.WriteJSON (resp, result); | 
|---|
| [244] | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | } | 
|---|
|  | 34 |  | 
|---|
|  | 35 | } | 
|---|
|  | 36 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.