Changeset 426 for binary-improvements2/WebServer/src/UrlHandlers
- Timestamp:
- Apr 24, 2023, 2:40:34 PM (19 months ago)
- Location:
- binary-improvements2/WebServer/src/UrlHandlers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/UrlHandlers/AbsHandler.cs
r404 r426 12 12 protected AbsHandler (string _moduleName, int _defaultPermissionLevel = 0) { 13 13 moduleName = _moduleName; 14 AdminWebModules.Instance.AddKnownModule ( _moduleName, _defaultPermissionLevel);14 AdminWebModules.Instance.AddKnownModule (new AdminWebModules.WebModule(_moduleName, _defaultPermissionLevel, true)); 15 15 } 16 16 -
binary-improvements2/WebServer/src/UrlHandlers/SseHandler.cs
r404 r426 53 53 public void AddEvent (string _eventName, AbsEvent _eventInstance) { 54 54 events.Add (_eventName, _eventInstance); 55 AdminWebModules.Instance.AddKnownModule ( $"webevent.{_eventName}", _eventInstance.DefaultPermissionLevel ());55 AdminWebModules.Instance.AddKnownModule (new AdminWebModules.WebModule($"webevent.{_eventName}", _eventInstance.DefaultPermissionLevel (), true)); 56 56 } 57 57 -
binary-improvements2/WebServer/src/UrlHandlers/UserStatusHandler.cs
r404 r426 16 16 private static readonly byte[] jsonAllowedKey = JsonWriter.GetEncodedPropertyNameWithPrefixValueSeparator ("allowed"); 17 17 18 private static readonly byte[][] jsonMethodNameKeys; 19 20 static UserStatusHandler () { 21 jsonMethodNameKeys = new byte[(int)ERequestMethod.Count][]; 22 for (int i = 0; i < jsonMethodNameKeys.Length; i++) { 23 ERequestMethod method = (ERequestMethod)i; 24 jsonMethodNameKeys [i] = JsonWriter.GetEncodedPropertyName (method.ToStringCached ()); 25 } 26 } 27 18 28 public override void HandleRequest (RequestContext _context) { 19 29 WebUtils.PrepareEnvelopedResult (out JsonWriter writer); … … 32 42 33 43 List<AdminWebModules.WebModule> list = AdminWebModules.Instance.GetModules (); 34 for (int i = 0; i < list.Count; i++) {35 AdminWebModules.WebModule perm = list [i ];44 for (int iModule = 0; iModule < list.Count; iModule++) { 45 AdminWebModules.WebModule perm = list [iModule]; 36 46 37 if (i > 0) {47 if (iModule > 0) { 38 48 writer.WriteValueSeparator (); 39 49 } … … 43 53 44 54 writer.WriteRaw (jsonAllowedKey); 45 writer.WriteBoolean (perm.PermissionLevel >= _context.PermissionLevel); 55 56 writer.WriteBeginObject (); 57 58 if (perm.LevelPerMethod == null) { 59 writer.WriteRaw (jsonMethodNameKeys [(int)ERequestMethod.GET]); 60 writer.WriteBoolean (perm.LevelGlobal >= _context.PermissionLevel); 61 } else { 62 bool first = true; 63 for (int iMethod = 0; iMethod < perm.LevelPerMethod.Length; iMethod++) { 64 int methodLevel = perm.LevelPerMethod [iMethod]; 65 66 if (methodLevel == AdminWebModules.MethodLevelNotSupported) { 67 continue; 68 } 69 70 if (methodLevel == AdminWebModules.MethodLevelInheritGlobal) { 71 methodLevel = perm.LevelGlobal; 72 } 73 74 if (!first) { 75 writer.WriteValueSeparator (); 76 } 77 78 first = false; 79 80 writer.WriteRaw (jsonMethodNameKeys [iMethod]); 81 writer.WriteBoolean (methodLevel >= _context.PermissionLevel); 82 } 83 } 84 85 writer.WriteEndObject (); 86 46 87 47 88 writer.WriteEndObject ();
Note:
See TracChangeset
for help on using the changeset viewer.