Line | |
---|
1 | using AllocsFixes.JSON;
|
---|
2 |
|
---|
3 | namespace Webserver.UrlHandlers {
|
---|
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.