Last change
on this file since 386 was 382, checked in by alloc, 2 years ago |
Switched to use SpaceWizards.HttpListener
|
File size:
1.2 KB
|
Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 | using AllocsFixes.NetConnections.Servers.Web.API;
|
---|
3 | using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
|
---|
4 | using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
|
---|
5 |
|
---|
6 | namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
|
---|
7 | public class UserStatusHandler : AbsHandler {
|
---|
8 | public UserStatusHandler (string _moduleName = null) : base (_moduleName) {
|
---|
9 | }
|
---|
10 |
|
---|
11 | public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con,
|
---|
12 | int _permissionLevel) {
|
---|
13 | JSONObject result = new JSONObject ();
|
---|
14 |
|
---|
15 | result.Add ("loggedin", new JSONBoolean (_con != null));
|
---|
16 | result.Add ("username", new JSONString (_con != null ? _con.UserId.ToString () : string.Empty));
|
---|
17 |
|
---|
18 | JSONArray perms = new JSONArray ();
|
---|
19 | foreach (WebPermissions.WebModulePermission perm in WebPermissions.Instance.GetModules ()) {
|
---|
20 | JSONObject permObj = new JSONObject ();
|
---|
21 | permObj.Add ("module", new JSONString (perm.module));
|
---|
22 | permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _permissionLevel));
|
---|
23 | perms.Add (permObj);
|
---|
24 | }
|
---|
25 |
|
---|
26 | result.Add ("permissions", perms);
|
---|
27 |
|
---|
28 | WebAPI.WriteJSON (_resp, result);
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.