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
|
Rev | Line | |
---|
[244] | 1 | using AllocsFixes.JSON;
|
---|
[325] | 2 | using AllocsFixes.NetConnections.Servers.Web.API;
|
---|
[382] | 3 | using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
|
---|
| 4 | using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
|
---|
[244] | 5 |
|
---|
[325] | 6 | namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
|
---|
[382] | 7 | public class UserStatusHandler : AbsHandler {
|
---|
[351] | 8 | public UserStatusHandler (string _moduleName = null) : base (_moduleName) {
|
---|
[244] | 9 | }
|
---|
| 10 |
|
---|
[382] | 11 | public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con,
|
---|
[351] | 12 | int _permissionLevel) {
|
---|
[244] | 13 | JSONObject result = new JSONObject ();
|
---|
| 14 |
|
---|
[382] | 15 | result.Add ("loggedin", new JSONBoolean (_con != null));
|
---|
| 16 | result.Add ("username", new JSONString (_con != null ? _con.UserId.ToString () : string.Empty));
|
---|
[244] | 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));
|
---|
[351] | 22 | permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _permissionLevel));
|
---|
[244] | 23 | perms.Add (permObj);
|
---|
| 24 | }
|
---|
[325] | 25 |
|
---|
[244] | 26 | result.Add ("permissions", perms);
|
---|
| 27 |
|
---|
[351] | 28 | WebAPI.WriteJSON (_resp, result);
|
---|
[244] | 29 | }
|
---|
| 30 | }
|
---|
[325] | 31 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.