Added DB backing for user profiles

Added "create profile command"
0.1-prestable
gareth 2007-04-02 12:19:13 +00:00
parent 906526bb9a
commit 9a0b105ad7
2 changed files with 46 additions and 4 deletions

View File

@ -107,9 +107,35 @@ namespace OpenGridServices.UserServer
m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
break;
case "shutdown":
case "create user":
m_console.WriteLine("Creating new user profile");
string tempfirstname;
string templastname;
string tempMD5Passwd;
tempfirstname=m_console.CmdPrompt("First name: ");
templastname=m_console.CmdPrompt("Last name: ");
tempMD5Passwd=m_console.PasswdPrompt("Password: ");
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
bs = x.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
tempMD5Passwd = "$1$" + s.ToString();
UserProfile newuser=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
newuser.homepos = new LLVector3(128f,128f,23f);
_profilemanager.SaveUserProfiles();
break;
case "shutdown":
m_console.Close();
Environment.Exit(0);
Environment.Exit(0);
break;
}
}

View File

@ -28,6 +28,22 @@ namespace OpenSim.Framework.User
db.Close();
}
public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT!
{
IObjectContainer db;
db = Db4oFactory.OpenFile("userprofiles.yap");
IObjectSet result = db.Get(typeof(UserProfile));
foreach (UserProfile userprof in result) {
db.Delete(userprof);
db.Commit();
}
foreach (UserProfile userprof in UserProfiles.Values) {
db.Set(userprof);
db.Commit();
}
db.Close();
}
public UserProfile GetProfileByName(string firstname, string lastname)
{
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
@ -86,8 +102,8 @@ namespace OpenSim.Framework.User
newprofile.UUID = LLUUID.Random();
newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
this.UserProfiles.Add(newprofile.UUID, newprofile);
return newprofile;
}
return newprofile;
}
public virtual AgentInventory GetUsersInventory(LLUUID agentID)
{