diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 969bdd8f26..1ac5fe463e 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -256,6 +256,18 @@ namespace OpenSim.Framework.Communications
return userProf.ID;
}
}
+
+ ///
+ /// Reset a user password
+ ///
+ ///
+ ///
+ ///
+ /// true if the update was successful, false otherwise
+ public bool ResetUserPassword(string firstName, string lastName, string newPassword)
+ {
+ return m_userService.ResetUserPassword(firstName, lastName, newPassword);
+ }
#region Friend Methods
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 7e3c77be40..d52d1eab8e 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Framework.Communications
UserProfileData SetupMasterUser(UUID userId);
///
- ///
+ /// Add a new user profile
///
///
UUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY);
@@ -71,6 +71,15 @@ namespace OpenSim.Framework.Communications
/// via a call to GetUserProfile().
/// true if the update could be applied, false if it could not be applied.
bool UpdateUserProfile(UserProfileData data);
+
+ ///
+ /// Reset a user password
+ ///
+ ///
+ ///
+ ///
+ /// true if the update was successful, false otherwise
+ bool ResetUserPassword(string firstName, string lastName, string newPassword);
///
/// Adds a new friend to the database for XUser
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index 75c4dc195c..4fc2fea333 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -361,8 +361,6 @@ namespace OpenSim.Framework.Communications
/// The users loginrequest
public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
{
- Hashtable requestData = (Hashtable) request.Params[0];
-
UserAgentData agent = new UserAgentData();
// User connection
@@ -574,6 +572,33 @@ namespace OpenSim.Framework.Communications
return user.ID;
}
+
+ ///
+ /// Reset a user password
+ ///
+ ///
+ ///
+ ///
+ /// true if the update was successful, false otherwise
+ public bool ResetUserPassword(string firstName, string lastName, string newPassword)
+ {
+ string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty);
+
+ UserProfileData profile = GetUserProfile(firstName, lastName);
+
+ if (null == profile)
+ {
+ m_log.ErrorFormat("[USERSTORAGE]: Could not find user {0} {1}", firstName, lastName);
+ return false;
+ }
+
+ profile.PasswordHash = md5PasswdHash;
+ profile.PasswordSalt = String.Empty;
+
+ UpdateUserProfile(profile);
+
+ return true;
+ }
public bool UpdateUserProfileProperties(UserProfileData UserProfile)
{
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 4cf34bc059..12ef1293be 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -283,6 +283,7 @@ namespace OpenSim
{
m_console.Notice("");
m_console.Notice("create user - adds a new user.");
+ m_console.Notice("reset user password - reset a user's password.");
}
break;
@@ -493,6 +494,10 @@ namespace OpenSim
m_commsManager.AddInventoryService(cmdparams[0]);
}
break;
+
+ case "reset":
+ Reset(cmdparams);
+ break;
default:
string[] tmpPluginArgs = new string[cmdparams.Length + 1];
@@ -543,6 +548,30 @@ namespace OpenSim
break;
}
}
+
+ ///
+ /// Execute switch for some of the reset commands
+ ///
+ ///
+ protected void Reset(string[] args)
+ {
+ if (args.Length == 0)
+ return;
+
+ switch (args[0])
+ {
+ case "user":
+
+ switch (args[1])
+ {
+ case "password":
+ ResetUserPassword(args);
+ break;
+ }
+
+ break;
+ }
+ }
///
/// Turn on some debugging values for OpenSim.
@@ -650,6 +679,7 @@ namespace OpenSim
{
m_console.Notice("");
m_console.Notice("create user - adds a new user.");
+ m_console.Notice("reset user password - reset a user's password.");
}
}
@@ -769,6 +799,31 @@ namespace OpenSim
m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
}
}
+
+ ///
+ /// Reset a user password.
+ ///
+ ///
+ private void ResetUserPassword(string[] cmdparams)
+ {
+ string firstName;
+ string lastName;
+ string newPassword;
+
+ if (cmdparams.Length < 3)
+ firstName = MainConsole.Instance.CmdPrompt("First name");
+ else firstName = cmdparams[2];
+
+ if ( cmdparams.Length < 4 )
+ lastName = MainConsole.Instance.CmdPrompt("Last name");
+ else lastName = cmdparams[3];
+
+ if ( cmdparams.Length < 5 )
+ newPassword = MainConsole.Instance.PasswdPrompt("New password");
+ else newPassword = cmdparams[4];
+
+ m_commsManager.ResetUserPassword(firstName, lastName, newPassword);
+ }
protected void SaveXml(string[] cmdparams)
{
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index b8268ebb81..0ca85d2ca0 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -469,6 +469,11 @@ namespace OpenSim.Region.Communications.OGS1
{
throw new Exception("The method or operation is not implemented.");
}
+
+ public bool ResetUserPassword(string firstName, string lastName, string newPassword)
+ {
+ throw new Exception("The method or operation is not implemented.");
+ }
// TODO
public bool UpdateUserProfile(UserProfileData data)