implement email field for MySQL and SQLite

From: Sean Dague <sdague@gmail.com>
0.6.0-stable
Sean Dague 2008-11-04 14:54:42 +00:00
parent 6e14d1005a
commit 702249358b
7 changed files with 37 additions and 17 deletions

View File

@ -540,6 +540,7 @@ namespace OpenSim.Data.MySQL
retval.ID = id;
retval.FirstName = (string) reader["username"];
retval.SurName = (string) reader["lastname"];
retval.Email = (string) reader["email"];
retval.PasswordHash = (string) reader["passwordHash"];
retval.PasswordSalt = (string) reader["passwordSalt"];
@ -768,7 +769,7 @@ namespace OpenSim.Data.MySQL
/// <param name="firstImage">UUID for firstlife image</param>
/// <param name="webLoginKey">Ignored</param>
/// <returns>Success?</returns>
public bool insertUserRow(UUID uuid, string username, string lastname, string passwordHash,
public bool insertUserRow(UUID uuid, string username, string lastname, string email, string passwordHash,
string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
@ -777,14 +778,14 @@ namespace OpenSim.Data.MySQL
{
m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString());
string sql =
"INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
"INSERT INTO users (`UUID`, `username`, `lastname`, `email`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
sql +=
"`homeLocationX`, `homeLocationY`, `homeLocationZ`, `homeLookAtX`, `homeLookAtY`, `homeLookAtZ`, `created`, ";
sql +=
"`lastLogin`, `userInventoryURI`, `userAssetURI`, `profileCanDoMask`, `profileWantDoMask`, `profileAboutText`, ";
sql += "`profileFirstText`, `profileImage`, `profileFirstImage`, `webLoginKey`, `userFlags`, `godLevel`, `customType`, `partner`) VALUES ";
sql += "(?UUID, ?username, ?lastname, ?passwordHash, ?passwordSalt, ?homeRegion, ";
sql += "(?UUID, ?username, ?lastname, ?email, ?passwordHash, ?passwordSalt, ?homeRegion, ";
sql +=
"?homeLocationX, ?homeLocationY, ?homeLocationZ, ?homeLookAtX, ?homeLookAtY, ?homeLookAtZ, ?created, ";
sql +=
@ -793,10 +794,11 @@ namespace OpenSim.Data.MySQL
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["?UUID"] = uuid.ToString();
parameters["?username"] = username.ToString();
parameters["?lastname"] = lastname.ToString();
parameters["?passwordHash"] = passwordHash.ToString();
parameters["?passwordSalt"] = passwordSalt.ToString();
parameters["?username"] = username;
parameters["?lastname"] = lastname;
parameters["?email"] = email;
parameters["?passwordHash"] = passwordHash;
parameters["?passwordSalt"] = passwordSalt;
parameters["?homeRegion"] = homeRegion.ToString();
parameters["?homeLocationX"] = homeLocX.ToString();
parameters["?homeLocationY"] = homeLocY.ToString();
@ -869,14 +871,14 @@ namespace OpenSim.Data.MySQL
/// <param name="firstImage">UUID for firstlife image</param>
/// <param name="webLoginKey">UUID for weblogin Key</param>
/// <returns>Success?</returns>
public bool updateUserRow(UUID uuid, string username, string lastname, string passwordHash,
public bool updateUserRow(UUID uuid, string username, string lastname, string email, string passwordHash,
string passwordSalt, UInt64 homeRegion, UUID homeRegionID, float homeLocX, float homeLocY, float homeLocZ,
float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
string aboutText, string firstText,
UUID profileImage, UUID firstImage, UUID webLoginKey, int userFlags, int godLevel, string customType, UUID partner)
{
string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname ";
string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname, `email` = ?email ";
sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , ";
sql += "`homeRegion` = ?homeRegion , `homeRegionID` = ?homeRegionID, `homeLocationX` = ?homeLocationX , ";
sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , ";
@ -892,10 +894,11 @@ namespace OpenSim.Data.MySQL
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["?UUID"] = uuid.ToString();
parameters["?username"] = username.ToString();
parameters["?lastname"] = lastname.ToString();
parameters["?passwordHash"] = passwordHash.ToString();
parameters["?passwordSalt"] = passwordSalt.ToString();
parameters["?username"] = username;
parameters["?lastname"] = lastname;
parameters["?email"] = email;
parameters["?passwordHash"] = passwordHash;
parameters["?passwordSalt"] = passwordSalt;
parameters["?homeRegion"] = homeRegion.ToString();
parameters["?homeRegionID"] = homeRegionID.ToString();
parameters["?homeLocationX"] = homeLocX.ToString();

View File

@ -642,7 +642,7 @@ namespace OpenSim.Data.MySQL
try
{
dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt,
dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
user.HomeRegion, user.HomeLocation.X, user.HomeLocation.Y,
user.HomeLocation.Z,
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
@ -697,7 +697,7 @@ namespace OpenSim.Data.MySQL
MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile");
try
{
dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.PasswordHash, user.PasswordSalt,
dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
user.HomeLocation.Z, user.HomeLookAt.X,
user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,

View File

@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE users add email varchar(250);
COMMIT;

View File

@ -0,0 +1,5 @@
BEGIN TRANSACTION;
ALTER TABLE users add email varchar(250);
COMMIT;

View File

@ -710,6 +710,7 @@ namespace OpenSim.Data.SQLite
SQLiteUtil.createCol(users, "UUID", typeof (String));
SQLiteUtil.createCol(users, "username", typeof (String));
SQLiteUtil.createCol(users, "surname", typeof (String));
SQLiteUtil.createCol(users, "email", typeof (String));
SQLiteUtil.createCol(users, "passwordHash", typeof (String));
SQLiteUtil.createCol(users, "passwordSalt", typeof (String));
@ -812,6 +813,7 @@ namespace OpenSim.Data.SQLite
user.ID = tmp;
user.FirstName = (String) row["username"];
user.SurName = (String) row["surname"];
user.Email = (String) row["email"];
user.PasswordHash = (String) row["passwordHash"];
user.PasswordSalt = (String) row["passwordSalt"];
@ -864,6 +866,7 @@ namespace OpenSim.Data.SQLite
row["UUID"] = Util.ToRawUuidString(user.ID);
row["username"] = user.FirstName;
row["surname"] = user.SurName;
row["email"] = user.Email;
row["passwordHash"] = user.PasswordHash;
row["passwordSalt"] = user.PasswordSalt;

View File

@ -135,6 +135,9 @@ namespace OpenSim.Data.Tests
Assert.That(user1,Is.EqualTo(u1a.ID));
Assert.That(user2,Is.EqualTo(u2a.ID));
Assert.That(user3,Is.EqualTo(u3a.ID));
// and one email test
Assert.That(u1.Email, Is.EqualTo(u1a.Email));
}
[Test]
@ -296,7 +299,8 @@ namespace OpenSim.Data.Tests
u.FirstName = fname;
u.SurName = lname;
u.PasswordHash = "NOTAHASH";
u.PasswordSalt = "NOTSALT";
u.PasswordSalt = "NOTSALT";
u.Email = "nobody@nodomain.nocc";
// MUST specify at least these 5 parameters or an exception is raised
return u;

View File

@ -124,7 +124,7 @@ namespace OpenSim.Framework
/// <summary>
/// A valid email address for the account. Useful for password reset requests.
/// </summary>
private string _email;
private string _email = String.Empty;
/// <summary>
/// A URI to the users asset server, used for foreigners and large grids.