source:
binary-improvements2/MapRendering/Web/Handlers/UserStatusHandler.cs@
389
| Last change on this file since 389 was 387, checked in by , 3 years ago | |
|---|---|
| File size: 992 bytes | |
| Line | |
|---|---|
| 1 | using AllocsFixes.JSON; |
| 2 | |
| 3 | namespace AllocsFixes.NetConnections.Servers.Web.Handlers { |
| 4 | public class UserStatusHandler : AbsHandler { |
| 5 | public UserStatusHandler (string _moduleName = null) : base (_moduleName) { |
| 6 | } |
| 7 | |
| 8 | public override void HandleRequest (RequestContext _context) { |
| 9 | JSONObject result = new JSONObject (); |
| 10 | |
| 11 | result.Add ("loggedin", new JSONBoolean (_context.Connection != null)); |
| 12 | result.Add ("username", new JSONString (_context.Connection != null ? _context.Connection.UserId.ToString () : string.Empty)); |
| 13 | |
| 14 | JSONArray perms = new JSONArray (); |
| 15 | foreach (WebPermissions.WebModulePermission perm in WebPermissions.Instance.GetModules ()) { |
| 16 | JSONObject permObj = new JSONObject (); |
| 17 | permObj.Add ("module", new JSONString (perm.module)); |
| 18 | permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _context.PermissionLevel)); |
| 19 | perms.Add (permObj); |
| 20 | } |
| 21 | |
| 22 | result.Add ("permissions", perms); |
| 23 | |
| 24 | WebUtils.WriteJson (_context.Response, result); |
| 25 | } |
| 26 | } |
| 27 | } |
Note:
See TracBrowser
for help on using the repository browser.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)