|
Last change
on this file since 388 was 387, checked in by alloc, 3 years ago |
|
Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time
|
|
File size:
992 bytes
|
| Rev | Line | |
|---|
| [244] | 1 | using AllocsFixes.JSON;
|
|---|
| 2 |
|
|---|
| [325] | 3 | namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
|
|---|
| [382] | 4 | public class UserStatusHandler : AbsHandler {
|
|---|
| [351] | 5 | public UserStatusHandler (string _moduleName = null) : base (_moduleName) {
|
|---|
| [244] | 6 | }
|
|---|
| 7 |
|
|---|
| [387] | 8 | public override void HandleRequest (RequestContext _context) {
|
|---|
| [244] | 9 | JSONObject result = new JSONObject ();
|
|---|
| 10 |
|
|---|
| [387] | 11 | result.Add ("loggedin", new JSONBoolean (_context.Connection != null));
|
|---|
| 12 | result.Add ("username", new JSONString (_context.Connection != null ? _context.Connection.UserId.ToString () : string.Empty));
|
|---|
| [244] | 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));
|
|---|
| [387] | 18 | permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _context.PermissionLevel));
|
|---|
| [244] | 19 | perms.Add (permObj);
|
|---|
| 20 | }
|
|---|
| [325] | 21 |
|
|---|
| [244] | 22 | result.Add ("permissions", perms);
|
|---|
| 23 |
|
|---|
| [387] | 24 | WebUtils.WriteJson (_context.Response, result);
|
|---|
| [244] | 25 | }
|
|---|
| 26 | }
|
|---|
| [325] | 27 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.