private void ShowUserCommand(List <string> args, Common.CmdIO.TTY io, UUID limitedToScene) { UserAccount account; if (args[0] == "help" || args.Count != 4) { io.Write("show user <firstname> <lastname>"); } else if (limitedToScene != UUID.Zero) { io.Write("show user not allowed on limited console"); } else if (m_UserAccountService.TryGetValue(args[2], args[3], out account)) { var sb = new StringBuilder(); sb.AppendFormat("ID: {0}\n", account.Principal.ID); sb.AppendFormat("First Name: {0}\n", account.Principal.FirstName); sb.AppendFormat("Last Name: {0}\n", account.Principal.LastName); sb.AppendFormat("Level: {0}\n", account.UserLevel); sb.AppendFormat("Title: {0}\n", account.UserTitle); sb.AppendFormat("Created: {0}\n", account.Created.ToString()); sb.AppendFormat("Email: {0}\n", account.Email); io.Write(sb.ToString()); } else { io.WriteFormatted("Account {0} {1} does not exist", args[2], args[3]); } }
private void HandleUserAccountChange(HttpRequest req, Map jsondata) { UserAccount account; UUID userid; if (!jsondata.TryGetValue("id", out userid)) { m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidRequest); return; } if (!m_UserAccountService.TryGetValue(userid, out account)) { m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.NotFound); return; } int ival; string sval; uint uval; if (jsondata.TryGetValue("userlevel", out ival)) { account.UserLevel = ival; if (account.UserLevel > 255) { m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.InvalidParameter); return; } } try { if (jsondata.TryGetValue("usertitle", out sval)) { m_UserAccountService.SetUserTitle(account.Principal.ID, sval); } if (jsondata.TryGetValue("userflags", out uval)) { m_UserAccountService.SetUserFlags(account.Principal.ID, (UserFlags)uval); } if (jsondata.TryGetValue("email", out sval)) { m_UserAccountService.SetEmail(account.Principal.ID, sval); } } catch { m_WebIF.ErrorResponse(req, AdminWebIfErrorResult.AlreadyExists); return; } m_WebIF.SuccessResponse(req, new Map()); }
public override UserInfo GetUserInfo(UGUI user) { UserAccount account; if (!m_UserAccountService.TryGetValue(user.ID, out account)) { throw new KeyNotFoundException(); } return(new UserInfo { FirstName = account.Principal.FirstName, LastName = account.Principal.LastName, UserCreated = account.Created, UserFlags = account.UserFlags, UserTitle = account.UserTitle }); }
private void CapsHandler(HttpRequest req) { string[] splitquery = req.RawUrl.Split('?'); string[] elements = splitquery[0].Substring(1).Split('/'); if (elements.Length < 3) { req.ErrorResponse(HttpStatusCode.NotFound, "Not found"); return; } UUID sessionid; if (!UUID.TryParse(elements[2], out sessionid)) { req.ErrorResponse(HttpStatusCode.NotFound, "Not found"); return; } bool foundIP = false; UUID agent = UUID.Zero; try { UserSessionInfo trv = m_UserSessionService[sessionid]; if (trv.ClientIPAddress == req.CallerIP) { agent = trv.User.ID; foundIP = true; } } catch { /* entry not found */ } UserAccount account; if (!foundIP || !m_UserAccountService.TryGetValue(agent, out account)) { req.ErrorResponse(HttpStatusCode.NotFound, "Not found"); return; } HandleHttpRequest(req, m_InventoryService, account.Principal); }