Changeset 474 for TFP-WebServer/WebServer/src/Permissions/AdminWebUsers.cs
- Timestamp:
- Aug 24, 2023, 12:48:17 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/WebServer/src/Permissions/AdminWebUsers.cs
r433 r474 43 43 44 44 public void AddUser (string _name, string _password, PlatformUserIdentifierAbs _userIdentifier, PlatformUserIdentifierAbs _crossPlatformIdentifier) { 45 WebUser p = new WebUser (_name, _password, _userIdentifier, _crossPlatformIdentifier); 46 47 // TODO: Check if another name exists with the same (crossplatform)identifier, remove that 48 users [_name] = p; 49 50 Parent.Save (); 45 lock (Parent) { 46 WebUser p = new WebUser (_name, _password, _userIdentifier, _crossPlatformIdentifier); 47 48 // TODO: Check if another name exists with the same (crossplatform)identifier, remove that 49 users[_name] = p; 50 51 Parent.Save (); 52 } 51 53 } 52 54 53 55 public bool RemoveUser (string _name) { 54 bool removed = users.Remove (_name); 55 if (removed) { 56 Parent.Save (); 56 lock (Parent) { 57 bool removed = users.Remove (_name); 58 if (removed) { 59 Parent.Save (); 60 } 61 62 return removed; 57 63 } 58 59 return removed;60 64 } 61 65 62 66 public Dictionary<string, WebUser> GetUsers () { 63 return users; 67 lock (Parent) { 68 return users; 69 } 64 70 } 65 71 … … 134 140 135 141 public bool TryGetUser (string _name, string _password, out WebUser _result) { 136 if (users.TryGetValue (_name, out _result) && _result.ValidatePassword (_password)) { 137 return true; 142 lock (Parent) { 143 if (users.TryGetValue (_name, out _result) && _result.ValidatePassword (_password)) { 144 return true; 145 } 146 147 _result = default; 148 return false; 138 149 } 139 140 _result = default;141 return false;142 150 } 143 151 144 152 public bool HasUser (PlatformUserIdentifierAbs _platformUser, PlatformUserIdentifierAbs _crossPlatformUser, out WebUser _result) { 145 _result = default; 146 147 foreach ((string _, WebUser webUser) in users) { 148 if (!PlatformUserIdentifierAbs.Equals (webUser.PlatformUser, _platformUser) || 149 !PlatformUserIdentifierAbs.Equals (webUser.CrossPlatformUser, _crossPlatformUser)) { 150 continue; 153 lock (Parent) { 154 _result = default; 155 156 foreach ((string _, WebUser webUser) in users) { 157 if (!PlatformUserIdentifierAbs.Equals (webUser.PlatformUser, _platformUser) || 158 !PlatformUserIdentifierAbs.Equals (webUser.CrossPlatformUser, _crossPlatformUser)) { 159 continue; 160 } 161 162 _result = webUser; 163 return true; 151 164 } 152 165 153 _result = webUser; 154 return true; 166 return false; 155 167 } 156 157 return false;158 168 } 159 169
Note:
See TracChangeset
for help on using the changeset viewer.