From b907a66f394b279d3ca2b1ac620bc7bb13cc6dd2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 4 Oct 2011 23:48:35 +0100 Subject: When creating a new user on the comand line, give the option of allowing a UUID to be specified to override the randomly generated one. This can be useful in some migration cases where recreating user accounts with known IDs will preserve region scene object ownership. --- OpenSim/Services/Interfaces/IUserAccountService.cs | 4 ++-- .../Services/UserAccountService/UserAccountService.cs | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index 9c992e0..20414f6 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -44,9 +44,9 @@ namespace OpenSim.Services.Interfaces PrincipalID = principalID; } - public UserAccount(UUID scopeID, string firstName, string lastName, string email) + public UserAccount(UUID scopeID, UUID principalID, string firstName, string lastName, string email) { - PrincipalID = UUID.Random(); + PrincipalID = principalID; ScopeID = scopeID; FirstName = firstName; LastName = lastName; diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index e071b94..923be7e 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -93,7 +93,7 @@ namespace OpenSim.Services.UserAccountService { MainConsole.Instance.Commands.AddCommand("UserService", false, "create user", - "create user [ [ [ []]]]", + "create user [ [ [ [ []]]]]", "Create a new user", HandleCreateUser); MainConsole.Instance.Commands.AddCommand("UserService", false, @@ -321,6 +321,7 @@ namespace OpenSim.Services.UserAccountService string lastName; string password; string email; + string rawPrincipalId; List excluded = new List(new char[]{' '}); @@ -340,7 +341,16 @@ namespace OpenSim.Services.UserAccountService email = MainConsole.Instance.CmdPrompt("Email", ""); else email = cmdparams[5]; - CreateUser(UUID.Zero, firstName, lastName, password, email); + if (cmdparams.Length < 7) + rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); + else + rawPrincipalId = cmdparams[6]; + + UUID principalId = UUID.Zero; + if (!UUID.TryParse(rawPrincipalId, out principalId)) + throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId)); + + CreateUser(UUID.Zero, principalId, firstName, lastName, password, email); } protected void HandleShowAccount(string module, string[] cmdparams) @@ -453,16 +463,17 @@ namespace OpenSim.Services.UserAccountService /// Create a user /// /// Allows hosting of multiple grids in a single database. Normally left as UUID.Zero + /// ID of the user /// /// /// /// - public UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email) + public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email) { UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); if (null == account) { - account = new UserAccount(UUID.Zero, firstName, lastName, email); + account = new UserAccount(UUID.Zero, principalID, firstName, lastName, email); if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) { account.ServiceURLs = new Dictionary(); -- cgit v1.1