diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index deadce25be..aba4f7b1fe 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -51,6 +51,7 @@ namespace OpenSim.Server.Handlers.UserAccounts private IUserAccountService m_UserAccountService; private bool m_AllowCreateUser = false; + private bool m_AllowSetAccount = false; public UserAccountServerPostHandler(IUserAccountService service) : this(service, null) {} @@ -61,7 +62,10 @@ namespace OpenSim.Server.Handlers.UserAccounts m_UserAccountService = service; if (config != null) + { m_AllowCreateUser = config.GetBoolean("AllowCreateUser", m_AllowCreateUser); + m_AllowSetAccount = config.GetBoolean("AllowSetAccount", m_AllowSetAccount); + } } public override byte[] Handle(string path, Stream requestData, @@ -99,8 +103,12 @@ namespace OpenSim.Server.Handlers.UserAccounts case "getaccounts": return GetAccounts(request); case "setaccount": - return StoreAccount(request); + if (m_AllowSetAccount) + return StoreAccount(request); + else + break; } + m_log.DebugFormat("[USER SERVICE HANDLER]: unknown method request: {0}", method); } catch (Exception e) @@ -193,8 +201,56 @@ namespace OpenSim.Server.Handlers.UserAccounts byte[] StoreAccount(Dictionary request) { - // No can do. No changing user accounts from remote sims - return FailureResult(); + UUID principalID = UUID.Zero; + if (!(request.ContainsKey("UserID") && UUID.TryParse(request["UserID"].ToString(), out principalID))) + return FailureResult(); + + UUID scopeID = UUID.Zero; + if (request.ContainsKey("ScopeID") && !UUID.TryParse(request["ScopeID"].ToString(), out scopeID)) + return FailureResult(); + + UserAccount existingAccount = m_UserAccountService.GetUserAccount(scopeID, principalID); + if (existingAccount == null) + return FailureResult(); + + Dictionary result = new Dictionary(); + + if (request.ContainsKey("FirstName")) + existingAccount.FirstName = request["FirstName"].ToString(); + + if (request.ContainsKey("LastName")) + existingAccount.LastName = request["LastName"].ToString(); + + if (request.ContainsKey("Email")) + existingAccount.Email = request["Email"].ToString(); + + int created = 0; + if (request.ContainsKey("Created") && int.TryParse(request["Created"].ToString(), out created)) + existingAccount.Created = created; + + int userLevel = 0; + if (request.ContainsKey("UserLevel") && int.TryParse(request["UserLevel"].ToString(), out userLevel)) + existingAccount.UserFlags = userLevel; + + int userFlags = 0; + if (request.ContainsKey("UserFlags") && int.TryParse(request["UserFlags"].ToString(), out userFlags)) + existingAccount.UserFlags = userFlags; + + if (request.ContainsKey("UserTitle")) + existingAccount.UserTitle = request["UserTitle"].ToString(); + + if (!m_UserAccountService.StoreUserAccount(existingAccount)) + { + m_log.ErrorFormat( + "[USER ACCOUNT SERVER POST HANDLER]: Account store failed for account {0} {1} {2}", + existingAccount.FirstName, existingAccount.LastName, existingAccount.PrincipalID); + + return FailureResult(); + } + + result["result"] = existingAccount.ToKeyValuePairs(); + + return ResultToBytes(result); } byte[] CreateUser(Dictionary request) diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index 962c2f4344..5958fc1aea 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -177,6 +177,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 ;; Default is false. ; AllowCreateUser = false + ;; Allow the service to process HTTP set account calls. + ;; Default is false. + ; AllowSetAccount = false + [GridUserService] ; for the server connector diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 661a15e9a1..2c8770ab56 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -154,13 +154,16 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 ;; This switch creates the minimum set of body parts and avatar entries for a viewer 2 ;; to show a default "Ruth" avatar rather than a cloud for a newly created user. ;; Default is false - ;; If you enable this you will also need to uncomment the AvatarService line above ; CreateDefaultAvatarEntries = false ;; Allow the service to process HTTP create user calls. ;; Default is false. ; AllowCreateUser = false + ;; Allow the service to process HTTP set account calls. + ;; Default is false. + ; AllowSetAccount = false + [GridUserService] ; for the server connector