private void ResetUserPasswordCommand(List <string> args, Common.CmdIO.TTY io, UUID limitedToScene) { UserAccount account; if (args[0] == "help" || args.Count < 5 || args[2] != "password") { io.Write("reset user password <firstname> <lastname>"); } else if (limitedToScene != UUID.Zero) { io.Write("reset user password not allowed on limited console"); } else if (m_UserAccountService.TryGetValue(args[3], args[4], out account)) { var authInfo = new UserAuthInfo { ID = account.Principal.ID, Password = io.GetPass("New password") }; m_AuthInfoService.Store(authInfo); } else { io.WriteFormatted("User \"{0}\" \"{1}\" not found", args[2], args[3]); } }
private void CreateUserCommand(List <string> args, Common.CmdIO.TTY io, UUID limitedToScene) { if (args[0] == "help" || args.Count != 4) { io.Write("create user <firstname> <lastname>"); } else if (limitedToScene != UUID.Zero) { io.Write("create user not allowed on limited console"); } else if (!IsNameValid(args[1]) || !IsNameValid(args[2])) { io.Write("name can only contains letters or digits"); } else if (m_UserAccountService.ContainsKey(args[1], args[2])) { io.Write("user already created"); } else { var account = new UserAccount { IsLocalToGrid = true }; account.Principal.ID = UUID.Random; account.Principal.FirstName = args[2]; account.Principal.LastName = args[3]; account.UserLevel = 0; var authInfo = new UserAuthInfo { ID = account.Principal.ID, Password = io.GetPass("Password") }; try { m_UserAccountService.Add(account); } catch { io.WriteFormatted("Could not add user account"); } try { m_AuthInfoService.Store(authInfo); } catch { m_UserAccountService.Remove(account.Principal.ID); io.WriteFormatted("Could not add user account"); } } }