* Moved command reset password from OpenSim to UserAccountService.

slimupdates
Diva Canto 2010-01-09 18:16:14 -08:00
parent 96ecdcf9c5
commit 7cb66de2e0
2 changed files with 37 additions and 47 deletions

View File

@ -347,13 +347,6 @@ namespace OpenSim
"kill uuid <UUID>",
"Kill an object by UUID", KillUUID);
if (ConfigurationSettings.Standalone)
{
m_console.Commands.AddCommand("region", false, "reset user password",
"reset user password [<first> [<last> [<password>]]]",
"Reset a user password", HandleResetUserPassword);
}
m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
"Set local coordinate to map HG regions to", RunCommand);
@ -809,21 +802,6 @@ namespace OpenSim
m_console.ConsoleScene = m_sceneManager.CurrentScene;
}
/// <summary>
/// Execute switch for some of the reset commands
/// </summary>
/// <param name="args"></param>
protected void HandleResetUserPassword(string module, string[] cmd)
{
if (ConfigurationSettings.Standalone)
{
ResetUserPassword(cmd);
}
else
{
m_log.Info("Reset user password is not available in grid mode, use the user-server.");
}
}
/// <summary>
/// Turn on some debugging values for OpenSim.
@ -1056,31 +1034,6 @@ namespace OpenSim
return report;
}
/// <summary>
/// Reset a user password.
/// </summary>
/// <param name="cmdparams"></param>
private void ResetUserPassword(string[] cmdparams)
{
string firstName;
string lastName;
string newPassword;
if (cmdparams.Length < 4)
firstName = MainConsole.Instance.CmdPrompt("First name");
else firstName = cmdparams[3];
if (cmdparams.Length < 5)
lastName = MainConsole.Instance.CmdPrompt("Last name");
else lastName = cmdparams[4];
if (cmdparams.Length < 6)
newPassword = MainConsole.Instance.PasswdPrompt("New password");
else newPassword = cmdparams[5];
m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
}
/// <summary>
/// Use XML2 format to serialize data to a file
/// </summary>

View File

@ -76,6 +76,10 @@ namespace OpenSim.Services.UserAccountService
"create user",
"create user [<first> [<last> [<pass> [<email>]]]]",
"Create a new user", HandleCreateUser);
MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password",
"reset user password [<first> [<last> [<password>]]]",
"Reset a user password", HandleResetUserPassword);
}
}
@ -292,6 +296,39 @@ namespace OpenSim.Services.UserAccountService
}
}
protected void HandleResetUserPassword(string module, string[] cmdparams)
{
string firstName;
string lastName;
string newPassword;
if (cmdparams.Length < 4)
firstName = MainConsole.Instance.CmdPrompt("First name");
else firstName = cmdparams[3];
if (cmdparams.Length < 5)
lastName = MainConsole.Instance.CmdPrompt("Last name");
else lastName = cmdparams[4];
if (cmdparams.Length < 6)
newPassword = MainConsole.Instance.PasswdPrompt("New password");
else newPassword = cmdparams[5];
UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
if (account == null)
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: No such user");
bool success = false;
if (m_AuthenticationService != null)
success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword);
if (!success)
m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Unable to reset password for account {0} {1}.",
firstName, lastName);
else
m_log.InfoFormat("[USER ACCOUNT SERVICE]: Password reset for user {0} {1}", firstName, lastName);
}
#endregion
}