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,6 +107,32 @@ namespace OpenGridServices.UserServer
m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"); m_console.WriteLine("shutdown - shutdown the grid (USE CAUTION!)");
break; break;
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": case "shutdown":
m_console.Close(); m_console.Close();
Environment.Exit(0); Environment.Exit(0);

View File

@ -28,6 +28,22 @@ namespace OpenSim.Framework.User
db.Close(); 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) public UserProfile GetProfileByName(string firstname, string lastname)
{ {
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)