diff options
author | Charles Krinke | 2008-11-23 03:38:40 +0000 |
---|---|---|
committer | Charles Krinke | 2008-11-23 03:38:40 +0000 |
commit | 02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8 (patch) | |
tree | f95a3170f3dd41be8ccf10957aef7209492a0279 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | |
parent | Add error handling to catch the WebExceptions thrown if you have (diff) | |
download | opensim-SC-02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8.zip opensim-SC-02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8.tar.gz opensim-SC-02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8.tar.bz2 opensim-SC-02fd7751d9b89d838fc8ca2dc60fe11f4cfe93a8.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs | 104 |
1 files changed, 101 insertions, 3 deletions
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 | |||
93 | m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod, false); | 93 | m_httpd.AddXmlRPCHandler("admin_restart", XmlRpcRestartMethod, false); |
94 | m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod, false); | 94 | m_httpd.AddXmlRPCHandler("admin_load_heightmap", XmlRpcLoadHeightmapMethod, false); |
95 | m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod, false); | 95 | m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod, false); |
96 | //This handler creates a user with a email, | ||
97 | m_httpd.AddXmlRPCHandler("admin_create_user_email", XmlRpcCreateUserMethodEmail, false); | ||
96 | m_httpd.AddXmlRPCHandler("admin_exists_user", XmlRpcUserExistsMethod, false); | 98 | m_httpd.AddXmlRPCHandler("admin_exists_user", XmlRpcUserExistsMethod, false); |
97 | m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod, false); | 99 | m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod, false); |
98 | m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod, false); | 100 | m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod, false); |
@@ -472,7 +474,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
472 | { | 474 | { |
473 | m_log.InfoFormat("master avatar does not exist, creating it"); | 475 | m_log.InfoFormat("master avatar does not exist, creating it"); |
474 | // ...or create new user | 476 | // ...or create new user |
475 | userID = m_app.CreateUser(masterFirst, masterLast, masterPassword, region.RegionLocX, region.RegionLocY); | 477 | userID = m_app.CreateUser(masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY); |
476 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | 478 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", |
477 | masterFirst, masterLast)); | 479 | masterFirst, masterLast)); |
478 | } | 480 | } |
@@ -647,7 +649,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
647 | 649 | ||
648 | // check completeness | 650 | // check completeness |
649 | checkStringParameters(request, new string[] { "password", "user_firstname", | 651 | checkStringParameters(request, new string[] { "password", "user_firstname", |
650 | "user_lastname", "user_password" }); | 652 | "user_lastname", "user_password", }); |
651 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); | 653 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); |
652 | 654 | ||
653 | // check password | 655 | // check password |
@@ -658,6 +660,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
658 | string firstname = (string) requestData["user_firstname"]; | 660 | string firstname = (string) requestData["user_firstname"]; |
659 | string lastname = (string) requestData["user_lastname"]; | 661 | string lastname = (string) requestData["user_lastname"]; |
660 | string passwd = (string) requestData["user_password"]; | 662 | string passwd = (string) requestData["user_password"]; |
663 | string email = ""; //Empty string for email | ||
661 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); | 664 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); |
662 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); | 665 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); |
663 | 666 | ||
@@ -665,7 +668,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
665 | if (null != userProfile) | 668 | if (null != userProfile) |
666 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); | 669 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); |
667 | 670 | ||
668 | UUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY); | 671 | UUID userID = m_app.CreateUser(firstname, lastname, passwd, email, regX, regY); |
669 | 672 | ||
670 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | 673 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", |
671 | firstname, lastname)); | 674 | firstname, lastname)); |
@@ -692,6 +695,101 @@ namespace OpenSim.ApplicationPlugins.RemoteController | |||
692 | return response; | 695 | return response; |
693 | } | 696 | } |
694 | 697 | ||
698 | /// <summary> | ||
699 | /// Create a new user account. | ||
700 | /// <summary> | ||
701 | /// <param name="request">incoming XML RPC request</param> | ||
702 | /// <remarks> | ||
703 | /// XmlRpcCreateUserMethod takes the following XMLRPC | ||
704 | /// parameters | ||
705 | /// <list type="table"> | ||
706 | /// <listheader><term>parameter name</term><description>description</description></listheader> | ||
707 | /// <item><term>password</term> | ||
708 | /// <description>admin password as set in OpenSim.ini</description></item> | ||
709 | /// <item><term>user_firstname</term> | ||
710 | /// <description>avatar's first name</description></item> | ||
711 | /// <item><term>user_lastname</term> | ||
712 | /// <description>avatar's last name</description></item> | ||
713 | /// <item><term>user_password</term> | ||
714 | /// <description>avatar's password</description></item> | ||
715 | /// <item><term>start_region_x</term> | ||
716 | /// <description>avatar's start region coordinates, X value</description></item> | ||
717 | /// <item><term>start_region_y</term> | ||
718 | /// <description>avatar's start region coordinates, Y value</description></item> | ||
719 | /// <item><term>user_email</term> | ||
720 | /// <description>email of avatar</description></item> | ||
721 | /// </list> | ||
722 | /// | ||
723 | /// XmlRpcCreateUserMethod returns | ||
724 | /// <list type="table"> | ||
725 | /// <listheader><term>name</term><description>description</description></listheader> | ||
726 | /// <item><term>success</term> | ||
727 | /// <description>true or false</description></item> | ||
728 | /// <item><term>error</term> | ||
729 | /// <description>error message if success is false</description></item> | ||
730 | /// <item><term>avatar_uuid</term> | ||
731 | /// <description>UUID of the newly created avatar | ||
732 | /// account; UUID.Zero if failed. | ||
733 | /// </description></item> | ||
734 | /// </list> | ||
735 | /// </remarks> | ||
736 | public XmlRpcResponse XmlRpcCreateUserMethodEmail(XmlRpcRequest request) | ||
737 | { | ||
738 | m_log.Info("[RADMIN]: CreateUser: new request"); | ||
739 | XmlRpcResponse response = new XmlRpcResponse(); | ||
740 | Hashtable responseData = new Hashtable(); | ||
741 | |||
742 | try | ||
743 | { | ||
744 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
745 | |||
746 | // check completeness | ||
747 | checkStringParameters(request, new string[] { "password", "user_firstname", | ||
748 | "user_lastname", "user_password", "user_email" }); | ||
749 | checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); | ||
750 | |||
751 | // check password | ||
752 | if (!String.IsNullOrEmpty(requiredPassword) && | ||
753 | (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); | ||
754 | |||
755 | // do the job | ||
756 | string firstname = (string)requestData["user_firstname"]; | ||
757 | string lastname = (string)requestData["user_lastname"]; | ||
758 | string passwd = (string)requestData["user_password"]; | ||
759 | string email = (string)requestData["user_email"]; | ||
760 | uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); | ||
761 | uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); | ||
762 | |||
763 | UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); | ||
764 | if (null != userProfile) | ||
765 | throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); | ||
766 | |||
767 | UUID userID = m_app.CreateUser(firstname, lastname, passwd, email, regX, regY); | ||
768 | |||
769 | if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", | ||
770 | firstname, lastname)); | ||
771 | |||
772 | responseData["success"] = "true"; | ||
773 | responseData["avatar_uuid"] = userID.ToString(); | ||
774 | |||
775 | response.Value = responseData; | ||
776 | |||
777 | m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); | ||
778 | } | ||
779 | catch (Exception e) | ||
780 | { | ||
781 | m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); | ||
782 | m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); | ||
783 | |||
784 | responseData["success"] = "false"; | ||
785 | responseData["avatar_uuid"] = UUID.Zero.ToString(); | ||
786 | responseData["error"] = e.Message; | ||
787 | |||
788 | response.Value = responseData; | ||
789 | } | ||
790 | |||
791 | return response; | ||
792 | } | ||
695 | 793 | ||
696 | /// <summary> | 794 | /// <summary> |
697 | /// Check whether a certain user account exists. | 795 | /// Check whether a certain user account exists. |