From 02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 23 Nov 2008 03:38:40 +0000 Subject: Mantis#2660. Thank you kindly, Ruud Lathrop for a patch that: This patch adds the option of adding the email when you create a new user. This works in Gridmode as none Gridmode. This option is also added to RemoteAdminPlugin. With a new handler you can create a user with a email. --- .../RemoteController/RemoteAdminPlugin.cs | 104 ++++++++++++++++++++- 1 file changed, 101 insertions(+), 3 deletions(-) (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 1490893..db99450 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -93,6 +93,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod, false); m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod, false); m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod, false); + //This handler creates a user with a email, + m_httpd.AddXmlRPCHandler("admin_create_user_email", XmlRpcCreateUserMethodEmail, false); m_httpd.AddXmlRPCHandler("admin_exists_user", XmlRpcUserExistsMethod, false); m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod, false); m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod, false); @@ -472,7 +474,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController { m_log.InfoFormat("master avatar does not exist, creating it"); // ...or create new user - userID = m_app.CreateUser(masterFirst, masterLast, masterPassword, region.RegionLocX, region.RegionLocY); + userID = m_app.CreateUser(masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY); if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", masterFirst, masterLast)); } @@ -647,7 +649,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController // check completeness checkStringParameters(request, new string[] { "password", "user_firstname", - "user_lastname", "user_password" }); + "user_lastname", "user_password", }); checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); // check password @@ -658,6 +660,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController string firstname = (string) requestData["user_firstname"]; string lastname = (string) requestData["user_lastname"]; string passwd = (string) requestData["user_password"]; + string email = ""; //Empty string for email uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); @@ -665,7 +668,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (null != userProfile) throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); - UUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY); + UUID userID = m_app.CreateUser(firstname, lastname, passwd, email, regX, regY); if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", firstname, lastname)); @@ -692,6 +695,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController return response; } + /// + /// Create a new user account. + /// + /// incoming XML RPC request + /// + /// XmlRpcCreateUserMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// user_firstname + /// avatar's first name + /// user_lastname + /// avatar's last name + /// user_password + /// avatar's password + /// start_region_x + /// avatar's start region coordinates, X value + /// start_region_y + /// avatar's start region coordinates, Y value + /// user_email + /// email of avatar + /// + /// + /// XmlRpcCreateUserMethod returns + /// + /// namedescription + /// success + /// true or false + /// error + /// error message if success is false + /// avatar_uuid + /// UUID of the newly created avatar + /// account; UUID.Zero if failed. + /// + /// + /// + public XmlRpcResponse XmlRpcCreateUserMethodEmail(XmlRpcRequest request) + { + m_log.Info("[RADMIN]: CreateUser: new request"); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + try + { + Hashtable requestData = (Hashtable)request.Params[0]; + + // check completeness + checkStringParameters(request, new string[] { "password", "user_firstname", + "user_lastname", "user_password", "user_email" }); + checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); + + // check password + if (!String.IsNullOrEmpty(requiredPassword) && + (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + + // do the job + string firstname = (string)requestData["user_firstname"]; + string lastname = (string)requestData["user_lastname"]; + string passwd = (string)requestData["user_password"]; + string email = (string)requestData["user_email"]; + uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); + uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); + + UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); + if (null != userProfile) + throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); + + UUID userID = m_app.CreateUser(firstname, lastname, passwd, email, regX, regY); + + if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", + firstname, lastname)); + + responseData["success"] = "true"; + responseData["avatar_uuid"] = userID.ToString(); + + response.Value = responseData; + + m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); + } + catch (Exception e) + { + m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); + m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); + + responseData["success"] = "false"; + responseData["avatar_uuid"] = UUID.Zero.ToString(); + responseData["error"] = e.Message; + + response.Value = responseData; + } + + return response; + } /// /// Check whether a certain user account exists. -- cgit v1.1