aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/UserAccountService
diff options
context:
space:
mode:
authorroot2011-06-30 00:26:03 +0100
committerroot2011-06-30 00:26:03 +0100
commit5f927dc104aac48707c0ea2ff77a3410c3857ecc (patch)
tree123324ae910db49349e7b07749f49cd172a3d037 /OpenSim/Services/UserAccountService
parentRemove friends debug spam (diff)
parentDon't follow inventory links of links. (diff)
downloadopensim-SC_OLD-5f927dc104aac48707c0ea2ff77a3410c3857ecc.zip
opensim-SC_OLD-5f927dc104aac48707c0ea2ff77a3410c3857ecc.tar.gz
opensim-SC_OLD-5f927dc104aac48707c0ea2ff77a3410c3857ecc.tar.bz2
opensim-SC_OLD-5f927dc104aac48707c0ea2ff77a3410c3857ecc.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services/UserAccountService')
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs97
1 files changed, 92 insertions, 5 deletions
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index cbd6f35..dbf5ef4 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -83,9 +83,24 @@ namespace OpenSim.Services.UserAccountService
83 "create user", 83 "create user",
84 "create user [<first> [<last> [<pass> [<email>]]]]", 84 "create user [<first> [<last> [<pass> [<email>]]]]",
85 "Create a new user", HandleCreateUser); 85 "Create a new user", HandleCreateUser);
86 MainConsole.Instance.Commands.AddCommand("UserService", false, "reset user password", 86
87 MainConsole.Instance.Commands.AddCommand("UserService", false,
88 "reset user password",
87 "reset user password [<first> [<last> [<password>]]]", 89 "reset user password [<first> [<last> [<password>]]]",
88 "Reset a user password", HandleResetUserPassword); 90 "Reset a user password", HandleResetUserPassword);
91
92 MainConsole.Instance.Commands.AddCommand("UserService", false,
93 "set user level",
94 "set user level [<first> [<last> [<level>]]]",
95 "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
96 + "this account will be treated as god-moded. "
97 + "It will also affect the 'login level' command. ",
98 HandleSetUserLevel);
99
100 MainConsole.Instance.Commands.AddCommand("UserService", false,
101 "show account",
102 "show account <first> <last>",
103 "Show account details for the given user", HandleShowAccount);
89 } 104 }
90 105
91 } 106 }
@@ -337,6 +352,36 @@ namespace OpenSim.Services.UserAccountService
337 CreateUser(firstName, lastName, password, email); 352 CreateUser(firstName, lastName, password, email);
338 } 353 }
339 354
355 protected void HandleShowAccount(string module, string[] cmdparams)
356 {
357 if (cmdparams.Length != 4)
358 {
359 MainConsole.Instance.Output("Usage: show account <first-name> <last-name>");
360 return;
361 }
362
363 string firstName = cmdparams[2];
364 string lastName = cmdparams[3];
365
366 UserAccount ua = GetUserAccount(UUID.Zero, firstName, lastName);
367
368 if (ua == null)
369 {
370 MainConsole.Instance.OutputFormat("No user named {0} {1}", firstName, lastName);
371 return;
372 }
373
374 MainConsole.Instance.OutputFormat("Name: {0}", ua.Name);
375 MainConsole.Instance.OutputFormat("ID: {0}", ua.PrincipalID);
376 MainConsole.Instance.OutputFormat("Title: {0}", ua.UserTitle);
377 MainConsole.Instance.OutputFormat("E-mail: {0}", ua.Email);
378 MainConsole.Instance.OutputFormat("Created: {0}", Utils.UnixTimeToDateTime(ua.Created));
379 MainConsole.Instance.OutputFormat("Level: {0}", ua.UserLevel);
380 MainConsole.Instance.OutputFormat("Flags: {0}", ua.UserFlags);
381 foreach (KeyValuePair<string, Object> kvp in ua.ServiceURLs)
382 MainConsole.Instance.OutputFormat("{0}: {1}", kvp.Key, kvp.Value);
383 }
384
340 protected void HandleResetUserPassword(string module, string[] cmdparams) 385 protected void HandleResetUserPassword(string module, string[] cmdparams)
341 { 386 {
342 string firstName; 387 string firstName;
@@ -357,16 +402,58 @@ namespace OpenSim.Services.UserAccountService
357 402
358 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); 403 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
359 if (account == null) 404 if (account == null)
360 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: No such user"); 405 {
406 MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName);
407 return;
408 }
361 409
362 bool success = false; 410 bool success = false;
363 if (m_AuthenticationService != null) 411 if (m_AuthenticationService != null)
364 success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword); 412 success = m_AuthenticationService.SetPassword(account.PrincipalID, newPassword);
413
414 if (!success)
415 MainConsole.Instance.OutputFormat("Unable to reset password for account {0} {1}.", firstName, lastName);
416 else
417 MainConsole.Instance.OutputFormat("Password reset for user {0} {1}", firstName, lastName);
418 }
419
420 protected void HandleSetUserLevel(string module, string[] cmdparams)
421 {
422 string firstName;
423 string lastName;
424 string rawLevel;
425 int level;
426
427 if (cmdparams.Length < 4)
428 firstName = MainConsole.Instance.CmdPrompt("First name");
429 else firstName = cmdparams[3];
430
431 if (cmdparams.Length < 5)
432 lastName = MainConsole.Instance.CmdPrompt("Last name");
433 else lastName = cmdparams[4];
434
435 UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName);
436 if (account == null) {
437 MainConsole.Instance.OutputFormat("No such user");
438 return;
439 }
440
441 if (cmdparams.Length < 6)
442 rawLevel = MainConsole.Instance.CmdPrompt("User level");
443 else rawLevel = cmdparams[5];
444
445 if(int.TryParse(rawLevel, out level) == false) {
446 MainConsole.Instance.OutputFormat("Invalid user level");
447 return;
448 }
449
450 account.UserLevel = level;
451
452 bool success = StoreUserAccount(account);
365 if (!success) 453 if (!success)
366 m_log.ErrorFormat("[USER ACCOUNT SERVICE]: Unable to reset password for account {0} {1}.", 454 MainConsole.Instance.OutputFormat("Unable to set user level for account {0} {1}.", firstName, lastName);
367 firstName, lastName);
368 else 455 else
369 m_log.InfoFormat("[USER ACCOUNT SERVICE]: Password reset for user {0} {1}", firstName, lastName); 456 MainConsole.Instance.OutputFormat("User level set for user {0} {1} to {2}", firstName, lastName, level);
370 } 457 }
371 458
372 #endregion 459 #endregion