aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService/UserAccountService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/UserAccountService/UserAccountService.cs')
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs40
1 files changed, 35 insertions, 5 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index e071b94..59098f0 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -93,7 +93,7 @@ namespace OpenSim.Services.UserAccountService
93 { 93 {
94 MainConsole.Instance.Commands.AddCommand("UserService", false, 94 MainConsole.Instance.Commands.AddCommand("UserService", false,
95 "create user", 95 "create user",
96 "create user [<first> [<last> [<pass> [<email>]]]]", 96 "create user [<first> [<last> [<pass> [<email> [<user id>]]]]]",
97 "Create a new user", HandleCreateUser); 97 "Create a new user", HandleCreateUser);
98 98
99 MainConsole.Instance.Commands.AddCommand("UserService", false, 99 MainConsole.Instance.Commands.AddCommand("UserService", false,
@@ -173,6 +173,10 @@ namespace OpenSim.Services.UserAccountService
173 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel); 173 Int32.TryParse(d.Data["UserLevel"], out u.UserLevel);
174 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null) 174 if (d.Data.ContainsKey("UserFlags") && d.Data["UserFlags"] != null)
175 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags); 175 Int32.TryParse(d.Data["UserFlags"], out u.UserFlags);
176 if (d.Data.ContainsKey("UserCountry") && d.Data["UserCountry"] != null)
177 u.UserCountry = d.Data["UserCountry"].ToString();
178 else
179 u.UserTitle = string.Empty;
176 180
177 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null) 181 if (d.Data.ContainsKey("ServiceURLs") && d.Data["ServiceURLs"] != null)
178 { 182 {
@@ -294,7 +298,22 @@ namespace OpenSim.Services.UserAccountService
294 298
295 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 299 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
296 { 300 {
297 UserAccountData[] d = m_Database.GetUsers(scopeID, query); 301 UserAccountData[] d = m_Database.GetUsers(scopeID, query.Trim());
302
303 if (d == null)
304 return new List<UserAccount>();
305
306 List<UserAccount> ret = new List<UserAccount>();
307
308 foreach (UserAccountData data in d)
309 ret.Add(MakeUserAccount(data));
310
311 return ret;
312 }
313
314 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string where)
315 {
316 UserAccountData[] d = m_Database.GetUsersWhere(scopeID, where);
298 317
299 if (d == null) 318 if (d == null)
300 return new List<UserAccount>(); 319 return new List<UserAccount>();
@@ -321,6 +340,7 @@ namespace OpenSim.Services.UserAccountService
321 string lastName; 340 string lastName;
322 string password; 341 string password;
323 string email; 342 string email;
343 string rawPrincipalId;
324 344
325 List<char> excluded = new List<char>(new char[]{' '}); 345 List<char> excluded = new List<char>(new char[]{' '});
326 346
@@ -340,7 +360,16 @@ namespace OpenSim.Services.UserAccountService
340 email = MainConsole.Instance.CmdPrompt("Email", ""); 360 email = MainConsole.Instance.CmdPrompt("Email", "");
341 else email = cmdparams[5]; 361 else email = cmdparams[5];
342 362
343 CreateUser(UUID.Zero, firstName, lastName, password, email); 363 if (cmdparams.Length < 7)
364 rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
365 else
366 rawPrincipalId = cmdparams[6];
367
368 UUID principalId = UUID.Zero;
369 if (!UUID.TryParse(rawPrincipalId, out principalId))
370 throw new Exception(string.Format("ID {0} is not a valid UUID", rawPrincipalId));
371
372 CreateUser(UUID.Zero, principalId, firstName, lastName, password, email);
344 } 373 }
345 374
346 protected void HandleShowAccount(string module, string[] cmdparams) 375 protected void HandleShowAccount(string module, string[] cmdparams)
@@ -453,16 +482,17 @@ namespace OpenSim.Services.UserAccountService
453 /// Create a user 482 /// Create a user
454 /// </summary> 483 /// </summary>
455 /// <param name="scopeID">Allows hosting of multiple grids in a single database. Normally left as UUID.Zero</param> 484 /// <param name="scopeID">Allows hosting of multiple grids in a single database. Normally left as UUID.Zero</param>
485 /// <param name="principalID">ID of the user</param>
456 /// <param name="firstName"></param> 486 /// <param name="firstName"></param>
457 /// <param name="lastName"></param> 487 /// <param name="lastName"></param>
458 /// <param name="password"></param> 488 /// <param name="password"></param>
459 /// <param name="email"></param> 489 /// <param name="email"></param>
460 public UserAccount CreateUser(UUID scopeID, string firstName, string lastName, string password, string email) 490 public UserAccount CreateUser(UUID scopeID, UUID principalID, string firstName, string lastName, string password, string email)
461 { 491 {
462 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); 492 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
463 if (null == account) 493 if (null == account)
464 { 494 {
465 account = new UserAccount(UUID.Zero, firstName, lastName, email); 495 account = new UserAccount(UUID.Zero, principalID, firstName, lastName, email);
466 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) 496 if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0))
467 { 497 {
468 account.ServiceURLs = new Dictionary<string, object>(); 498 account.ServiceURLs = new Dictionary<string, object>();