Changeset 474 for TFP-WebServer/WebServer/src/Permissions/AdminApiTokens.cs
- Timestamp:
- Aug 24, 2023, 12:48:17 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/Permissions/AdminApiTokens.cs
r440 r474 40 40 41 41 public void AddToken (string _name, string _secret, int _permissionLevel) { 42 ApiToken apiToken = new ApiToken (_name, _secret, _permissionLevel); 43 tokens [_name] = apiToken; 44 Parent.Save (); 42 lock (Parent) { 43 ApiToken apiToken = new ApiToken (_name, _secret, _permissionLevel); 44 tokens[_name] = apiToken; 45 Parent.Save (); 46 } 45 47 } 46 48 47 49 public bool RemoveToken (string _name) { 48 bool removed = tokens.Remove (_name); 49 if (removed) { 50 Parent.Save (); 50 lock (Parent) { 51 bool removed = tokens.Remove (_name); 52 if (removed) { 53 Parent.Save (); 54 } 55 56 return removed; 51 57 } 52 53 return removed;54 58 } 55 59 56 60 public Dictionary<string, ApiToken> GetTokens () { 57 return tokens; 61 lock (Parent) { 62 return tokens; 63 } 58 64 } 59 65 … … 113 119 114 120 public int GetPermissionLevel (string _name, string _secret) { 115 if (tokens.TryGetValue (_name, out ApiToken apiToken) && apiToken.Secret == _secret) { 116 return apiToken.PermissionLevel; 121 lock (Parent) { 122 if (tokens.TryGetValue (_name, out ApiToken apiToken) && apiToken.Secret == _secret) { 123 return apiToken.PermissionLevel; 124 } 125 126 if (IsCommandlineToken (_name, _secret)) { 127 return 0; 128 } 129 130 return int.MaxValue; 117 131 } 118 119 if (IsCommandlineToken (_name, _secret)) {120 return 0;121 }122 123 return int.MaxValue;124 132 } 125 133
Note:
See TracChangeset
for help on using the changeset viewer.