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.
0.6.1-post-fixes
Charles Krinke 2008-11-23 03:38:40 +00:00
parent 0460c19bcd
commit 02fd7751d9
11 changed files with 285 additions and 91 deletions

View File

@ -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;
}
/// <summary>
/// Create a new user account.
/// <summary>
/// <param name="request">incoming XML RPC request</param>
/// <remarks>
/// XmlRpcCreateUserMethod takes the following XMLRPC
/// parameters
/// <list type="table">
/// <listheader><term>parameter name</term><description>description</description></listheader>
/// <item><term>password</term>
/// <description>admin password as set in OpenSim.ini</description></item>
/// <item><term>user_firstname</term>
/// <description>avatar's first name</description></item>
/// <item><term>user_lastname</term>
/// <description>avatar's last name</description></item>
/// <item><term>user_password</term>
/// <description>avatar's password</description></item>
/// <item><term>start_region_x</term>
/// <description>avatar's start region coordinates, X value</description></item>
/// <item><term>start_region_y</term>
/// <description>avatar's start region coordinates, Y value</description></item>
/// <item><term>user_email</term>
/// <description>email of avatar</description></item>
/// </list>
///
/// XmlRpcCreateUserMethod returns
/// <list type="table">
/// <listheader><term>name</term><description>description</description></listheader>
/// <item><term>success</term>
/// <description>true or false</description></item>
/// <item><term>error</term>
/// <description>error message if success is false</description></item>
/// <item><term>avatar_uuid</term>
/// <description>UUID of the newly created avatar
/// account; UUID.Zero if failed.
/// </description></item>
/// </list>
/// </remarks>
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;
}
/// <summary>
/// Check whether a certain user account exists.

View File

@ -255,14 +255,15 @@ namespace OpenSim.Framework.Communications
/// <param name="firstName"></param>
/// <param name="lastName"></param>
/// <param name="password"></param>
/// <param name="email"></param>
/// <param name="regX"></param>
/// <param name="regY"></param>
/// <returns>The UUID of the added user. Returns UUID.Zero if the add was unsuccessful</returns>
public UUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY);
m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY);
UserProfileData userProf = UserService.GetUserProfile(firstName, lastName);
if (userProf == null)
{
@ -276,11 +277,22 @@ namespace OpenSim.Framework.Communications
}
}
public UUID AddUser(string firstName, string lastName, string password, uint regX, uint regY, UUID SetUUID)
/// <summary>
/// Adds the user.
/// </summary>
/// <param name="firstName">The first name.</param>
/// <param name="lastName">The last name.</param>
/// <param name="password">The password.</param>
/// <param name="email">The email.</param>
/// <param name="regX">The reg X.</param>
/// <param name="regY">The reg Y.</param>
/// <param name="SetUUID">The set UUID.</param>
/// <returns></returns>
public UUID AddUser(string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
{
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY, SetUUID);
m_userServiceAdmin.AddUserProfile(firstName, lastName, md5PasswdHash, email, regX, regY, SetUUID);
UserProfileData userProf = UserService.GetUserProfile(firstName, lastName);
if (userProf == null)
{

View File

@ -35,15 +35,15 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Loads a user profile by name
/// </summary>
/// <param name="fname">First name</param>
/// <param name="lname">Last name</param>
/// <param name="firstName">First name</param>
/// <param name="lastName">Last name</param>
/// <returns>A user profile. Returns null if no profile is found</returns>
UserProfileData GetUserProfile(string firstName, string lastName);
/// <summary>
/// Loads a user profile from a database by UUID
/// </summary>
/// <param name="uuid">The target UUID</param>
/// <param name="userId">The target UUID</param>
/// <returns>A user profile. Returns null if no user profile is found.</returns>
UserProfileData GetUserProfile(UUID userId);
@ -90,8 +90,8 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Logs off a user on the user server
/// </summary>
/// <param name="UserID">UUID of the user</param>
/// <param name="regionID">UUID of the Region</param>
/// <param name="userid">UUID of the user</param>
/// <param name="regionid">UUID of the Region</param>
/// <param name="regionhandle">regionhandle</param>
/// <param name="position">final position</param>
/// <param name="lookat">final lookat</param>
@ -100,8 +100,8 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Logs off a user on the user server (deprecated as of 2008-08-27)
/// </summary>
/// <param name="UserID">UUID of the user</param>
/// <param name="regionID">UUID of the Region</param>
/// <param name="userid">UUID of the user</param>
/// <param name="regionid">UUID of the Region</param>
/// <param name="regionhandle">regionhandle</param>
/// <param name="posx">final position x</param>
/// <param name="posy">final position y</param>
@ -118,7 +118,8 @@ namespace OpenSim.Framework.Communications
/// Updates the current region the User is in
/// </summary>
/// <param name="avatarid">User Region the Avatar is IN</param>
/// <param name="retionuuid">User Region the Avatar is IN</param>
/// <param name="regionuuid">User Region the Avatar is IN</param>
/// <param name="regionhandle">User region handle</param>
void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle);
/// <summary>

View File

@ -34,11 +34,27 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Add a new user profile
/// </summary>
/// <param name="user"></param>
UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY);
/// <param name="firstName">The first name.</param>
/// <param name="lastName">The last name.</param>
/// <param name="pass">password of avatar</param>
/// <param name="email">email of user</param>
/// <param name="regX">region X.</param>
/// <param name="regY">region Y.</param>
/// <returns></returns>
UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY);
// Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances!
UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY, UUID setUUID);
/// <summary>
/// Adds one for allowing setting of the UUID from modules.. SHOULD ONLY BE USED in very special circumstances!
/// </summary>
/// <param name="firstName">The first name.</param>
/// <param name="lastName">The last name.</param>
/// <param name="pass">password of avatar</param>
/// <param name="email">email of user</param>
/// <param name="regX">region X.</param>
/// <param name="regY">region Y.</param>
/// <param name="setUUID">The set UUID.</param>
/// <returns></returns>
UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID setUUID);
/// <summary>
/// Reset a user password

View File

@ -54,6 +54,7 @@ namespace OpenSim.Framework.Communications
/// Adds a new user server plugin - user servers will be requested in the order they were loaded.
/// </summary>
/// <param name="provider">The filename to the user server plugin DLL</param>
/// <param name="connect"></param>
public void AddPlugin(string provider, string connect)
{
PluginLoader<IUserDataPlugin> loader =
@ -580,15 +581,32 @@ namespace OpenSim.Framework.Communications
#endregion
/// <summary>
///
/// Add a new user profile
/// </summary>
/// <param name="user"></param>
public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
/// <param name="firstName">first name.</param>
/// <param name="lastName">last name.</param>
/// <param name="pass">password</param>
/// <param name="email">email.</param>
/// <param name="regX">location X.</param>
/// <param name="regY">location Y.</param>
/// <returns></returns>
public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY)
{
return AddUserProfile(firstName, lastName, pass, regX, regY, UUID.Random());
return AddUserProfile(firstName, lastName, pass, email, regX, regY, UUID.Random());
}
public UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY, UUID SetUUID)
/// <summary>
/// Adds the user profile.
/// </summary>
/// <param name="firstName">first name.</param>
/// <param name="lastName">last name.</param>
/// <param name="pass">password</param>
/// <param name="email">email.</param>
/// <param name="regX">location X.</param>
/// <param name="regY">location Y.</param>
/// <param name="SetUUID">UUID of avatar.</param>
/// <returns></returns>
public UUID AddUserProfile(string firstName, string lastName, string pass, string email, uint regX, uint regY, UUID SetUUID)
{
UserProfileData user = new UserProfileData();
user.HomeLocation = new Vector3(128, 128, 100);
@ -601,6 +619,7 @@ namespace OpenSim.Framework.Communications
user.HomeLookAt = new Vector3(100, 100, 100);
user.HomeRegionX = regX;
user.HomeRegionY = regY;
user.Email = email;
foreach (IUserDataPlugin plugin in _plugins)
{

View File

@ -162,62 +162,12 @@ namespace OpenSim.Grid.UserServer
m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
}
public void do_create(string what)
public void do_create(string[] args)
{
switch (what)
switch (args[0])
{
case "user":
string tempfirstname = m_console.CmdPrompt("First name");
string templastname = m_console.CmdPrompt("Last name");
//tempMD5Passwd = m_console.PasswdPrompt("Password");
string tempMD5Passwd = m_console.CmdPrompt("Password");
uint regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
uint regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
if (null != m_userManager.GetUserProfile(tempfirstname, templastname))
{
m_log.ErrorFormat(
"[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
break;
}
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
UUID userID = new UUID();
try
{
userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
}
catch (Exception ex)
{
m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
}
try
{
if (!m_interServiceInventoryService.CreateNewUserInventory(userID))
{
throw new Exception(
String.Format(
"The inventory creation request for user {0} did not succeed."
+ " Please contact your inventory service provider for more information.",
userID));
}
}
catch (WebException)
{
m_log.ErrorFormat(
"[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}",
Cfg.InventoryUrl + "CreateInventory/", userID);
}
catch (Exception e)
{
m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e);
}
m_lastCreatedUser = userID;
CreateUser(args);
break;
}
}
@ -246,6 +196,85 @@ namespace OpenSim.Grid.UserServer
}
}
/// <summary>
/// Create a new user
/// </summary>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
protected void CreateUser(string[] cmdparams)
{
string firstName;
string lastName;
string password;
string email;
uint regX = 1000;
uint regY = 1000;
if (cmdparams.Length < 2)
firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
else firstName = cmdparams[1];
if (cmdparams.Length < 3)
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
else lastName = cmdparams[2];
if (cmdparams.Length < 4)
password = MainConsole.Instance.PasswdPrompt("Password");
else password = cmdparams[3];
if (cmdparams.Length < 5)
regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
else regX = Convert.ToUInt32(cmdparams[4]);
if (cmdparams.Length < 6)
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
else regY = Convert.ToUInt32(cmdparams[5]);
if (cmdparams.Length < 7)
email = MainConsole.Instance.CmdPrompt("Email", "");
else email = cmdparams[6];
if (null == m_userManager.GetUserProfile(firstName, lastName))
{
password = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
UUID userID = new UUID();
try
{
userID = m_userManager.AddUserProfile(firstName, lastName, password, email, regX, regY);
}
catch (Exception ex)
{
m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
}
try
{
if (!m_interServiceInventoryService.CreateNewUserInventory(userID))
{
throw new Exception(
String.Format("The inventory creation request for user {0} did not succeed."
+ " Please contact your inventory service provider for more information.", userID));
}
}
catch (WebException)
{
m_log.ErrorFormat("[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}",
Cfg.InventoryUrl + "CreateInventory/", userID);
}
catch (Exception e)
{
m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e);
}
m_lastCreatedUser = userID;
}
else
{
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
}
}
/// <summary>
/// Reset a user password.
/// </summary>
@ -277,7 +306,7 @@ namespace OpenSim.Grid.UserServer
switch (cmd)
{
case "create":
do_create(cmdparams[0]);
do_create(cmdparams);
break;
case "reset":

View File

@ -516,7 +516,14 @@ namespace OpenSim
switch (args[0])
{
case "user":
CreateUser(args);
if (ConfigurationSettings.Standalone)
{
CreateUser(args);
}
else
{
m_console.Notice("Create user is not available in grid mode, use the user-server.");
}
break;
}
}
@ -537,7 +544,14 @@ namespace OpenSim
switch (args[1])
{
case "password":
ResetUserPassword(args);
if (ConfigurationSettings.Standalone)
{
ResetUserPassword(args);
}
else
{
m_console.Notice("Reset user password is not available in grid mode, use the user-server.");
}
break;
}
@ -734,12 +748,13 @@ namespace OpenSim
/// <summary>
/// Create a new user
/// </summary>
/// <param name="cmdparams"></param>
/// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
protected void CreateUser(string[] cmdparams)
{
string firstName;
string lastName;
string password;
string email;
uint regX = 1000;
uint regY = 1000;
@ -751,7 +766,7 @@ namespace OpenSim
lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
else lastName = cmdparams[2];
if ( cmdparams.Length < 4 )
if (cmdparams.Length < 4)
password = MainConsole.Instance.PasswdPrompt("Password");
else password = cmdparams[3];
@ -763,9 +778,13 @@ namespace OpenSim
regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
else regY = Convert.ToUInt32(cmdparams[5]);
if (cmdparams.Length < 7)
email = MainConsole.Instance.CmdPrompt("Email", "");
else email = cmdparams[6];
if (null == m_commsManager.UserService.GetUserProfile(firstName, lastName))
{
CreateUser(firstName, lastName, password, regX, regY);
CreateUser(firstName, lastName, password, email, regX, regY);
}
else
{

View File

@ -298,9 +298,9 @@ namespace OpenSim
m_assetCache = new AssetCache(assetServer);
}
public UUID CreateUser(string tempfirstname, string templastname, string tempPasswd, uint regX, uint regY)
public UUID CreateUser(string tempfirstname, string templastname, string tempPasswd, string email, uint regX, uint regY)
{
return m_commsManager.AddUser(tempfirstname, templastname, tempPasswd, regX, regY);
return m_commsManager.AddUser(tempfirstname, templastname, tempPasswd, email, regX, regY);
}
/// <summary>

View File

@ -94,7 +94,7 @@ namespace OpenSim.Region.Communications.Local
//no current user account so make one
m_log.Info("[LOGIN]: No user account found so creating a new one.");
m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
m_userManager.AddUserProfile(firstname, lastname, "test", "", defaultHomeX, defaultHomeY);
profile = m_userManager.GetUserProfile(firstname, lastname);
if (profile != null)

View File

@ -72,7 +72,7 @@ namespace OpenSim.Region.Communications.Local
}
Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
AddUserProfile(firstName, lastName, password, m_defaultHomeX, m_defaultHomeY);
AddUserProfile(firstName, lastName, password, "", m_defaultHomeX, m_defaultHomeY);
profile = GetUserProfile(firstName, lastName);

View File

@ -530,7 +530,7 @@ namespace OpenSim.Region.Environment.Modules.InterGrid
// get seed capagentData.firstname = FirstName;agentData.lastname = LastName;
if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode)
{
homeScene.CommsManager.AddUser(agentData.firstname, agentData.lastname, CreateRandomStr(7), homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
homeScene.CommsManager.AddUser(agentData.firstname, agentData.lastname, CreateRandomStr(7), "", homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID);
UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID);
if (userProfile2 != null)
{