aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs62
1 files changed, 59 insertions, 3 deletions
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index deadce2..aba4f7b 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
51 51
52 private IUserAccountService m_UserAccountService; 52 private IUserAccountService m_UserAccountService;
53 private bool m_AllowCreateUser = false; 53 private bool m_AllowCreateUser = false;
54 private bool m_AllowSetAccount = false;
54 55
55 public UserAccountServerPostHandler(IUserAccountService service) 56 public UserAccountServerPostHandler(IUserAccountService service)
56 : this(service, null) {} 57 : this(service, null) {}
@@ -61,7 +62,10 @@ namespace OpenSim.Server.Handlers.UserAccounts
61 m_UserAccountService = service; 62 m_UserAccountService = service;
62 63
63 if (config != null) 64 if (config != null)
65 {
64 m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser); 66 m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser);
67 m_AllowSetAccount = config.GetBoolean("AllowSetAccount", m_AllowSetAccount);
68 }
65 } 69 }
66 70
67 public override byte[] Handle(string path, Stream requestData, 71 public override byte[] Handle(string path, Stream requestData,
@@ -99,8 +103,12 @@ namespace OpenSim.Server.Handlers.UserAccounts
99 case "getaccounts": 103 case "getaccounts":
100 return GetAccounts(request); 104 return GetAccounts(request);
101 case "setaccount": 105 case "setaccount":
102 return StoreAccount(request); 106 if (m_AllowSetAccount)
107 return StoreAccount(request);
108 else
109 break;
103 } 110 }
111
104 m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); 112 m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method);
105 } 113 }
106 catch (Exception e) 114 catch (Exception e)
@@ -193,8 +201,56 @@ namespace OpenSim.Server.Handlers.UserAccounts
193 201
194 byte[] StoreAccount(Dictionary<string, object> request) 202 byte[] StoreAccount(Dictionary<string, object> request)
195 { 203 {
196 // No can do. No changing user accounts from remote sims 204 UUID principalID = UUID.Zero;
197 return FailureResult(); 205 if (!(request.ContainsKey("UserID") && UUID.TryParse(request["UserID"].ToString(), out principalID)))
206 return FailureResult();
207
208 UUID scopeID = UUID.Zero;
209 if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID))
210 return FailureResult();
211
212 UserAccount existingAccount = m_UserAccountService.GetUserAccount(scopeID, principalID);
213 if (existingAccount == null)
214 return FailureResult();
215
216 Dictionary<string, object> result = new Dictionary<string, object>();
217
218 if (request.ContainsKey("FirstName"))
219 existingAccount.FirstName = request["FirstName"].ToString();
220
221 if (request.ContainsKey("LastName"))
222 existingAccount.LastName = request["LastName"].ToString();
223
224 if (request.ContainsKey("Email"))
225 existingAccount.Email = request["Email"].ToString();
226
227 int created = 0;
228 if (request.ContainsKey("Created") && int.TryParse(request["Created"].ToString(), out created))
229 existingAccount.Created = created;
230
231 int userLevel = 0;
232 if (request.ContainsKey("UserLevel") && int.TryParse(request["UserLevel"].ToString(), out userLevel))
233 existingAccount.UserFlags = userLevel;
234
235 int userFlags = 0;
236 if (request.ContainsKey("UserFlags") && int.TryParse(request["UserFlags"].ToString(), out userFlags))
237 existingAccount.UserFlags = userFlags;
238
239 if (request.ContainsKey("UserTitle"))
240 existingAccount.UserTitle = request["UserTitle"].ToString();
241
242 if (!m_UserAccountService.StoreUserAccount(existingAccount))
243 {
244 m_log.ErrorFormat(
245 "[USER ACCOUNT SERVER POST HANDLER]: Account store failed for account {0} {1} {2}",
246 existingAccount.FirstName, existingAccount.LastName, existingAccount.PrincipalID);
247
248 return FailureResult();
249 }
250
251 result["result"] = existingAccount.ToKeyValuePairs();
252
253 return ResultToBytes(result);
198 } 254 }
199 255
200 byte[] CreateUser(Dictionary<string, object> request) 256 byte[] CreateUser(Dictionary<string, object> request)