From 7cb66de2e022d1013eacb43dc0186a575a19a5c6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 18:16:14 -0800 Subject: * Moved command reset password from OpenSim to UserAccountService. --- OpenSim/Region/Application/OpenSim.cs | 47 ---------------------- .../UserAccountService/UserAccountService.cs | 37 +++++++++++++++++ 2 files changed, 37 insertions(+), 47 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 787d025..31cc610 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -347,13 +347,6 @@ namespace OpenSim "kill uuid ", "Kill an object by UUID", KillUUID); - if (ConfigurationSettings.Standalone) - { - - m_console.Commands.AddCommand("region", false, "reset user password", - "reset user password [ [ []]]", - "Reset a user password", HandleResetUserPassword); - } m_console.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [ ] ", "Set local coordinate to map HG regions to", RunCommand); @@ -809,21 +802,6 @@ namespace OpenSim m_console.ConsoleScene = m_sceneManager.CurrentScene; } - /// - /// Execute switch for some of the reset commands - /// - /// - 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."); - } - } /// /// Turn on some debugging values for OpenSim. @@ -1057,31 +1035,6 @@ namespace OpenSim } /// - /// Reset a user password. - /// - /// - 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); - } - - /// /// Use XML2 format to serialize data to a file /// /// diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 8f78813..90077d8 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -76,6 +76,10 @@ namespace OpenSim.Services.UserAccountService "create user", "create user [ [ [ []]]]", "Create a new user", HandleCreateUser); + MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", + "reset user 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 } -- cgit v1.1