on iar save/load, let the user know if they put in the wrong password

refactor GetUserInfo() to eliminate copypasta
remotes/origin/0.6.7-post-fixes
Justin Clark-Casey (justincc) 2009-09-16 18:20:55 +01:00
parent 9cbb865985
commit 35260faead
2 changed files with 18 additions and 26 deletions

View File

@ -125,10 +125,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{ {
if (m_scenes.Count > 0) if (m_scenes.Count > 0)
{ {
CachedUserInfo userInfo = GetUserInfo(firstName, lastName); CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null) if (userInfo != null)
{ {
@ -153,11 +150,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{ {
if (m_scenes.Count > 0) if (m_scenes.Count > 0)
{ {
CachedUserInfo userInfo = GetUserInfo(firstName, lastName); CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null) if (userInfo != null)
{ {
@ -182,11 +175,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{ {
if (m_scenes.Count > 0) if (m_scenes.Count > 0)
{ {
CachedUserInfo userInfo = GetUserInfo(firstName, lastName); CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null) if (userInfo != null)
{ {
@ -214,11 +203,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{ {
if (m_scenes.Count > 0) if (m_scenes.Count > 0)
{ {
CachedUserInfo userInfo = GetUserInfo(firstName, lastName); CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass);
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
return false;
if (userInfo != null) if (userInfo != null)
{ {
@ -251,7 +236,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (cmdparams.Length < 6) if (cmdparams.Length < 6)
{ {
m_log.Error( m_log.Error(
"[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <password> [<load file path>]"); "[INVENTORY ARCHIVER]: usage is load iar <first name> <last name> <inventory path> <user password> [<load file path>]");
return; return;
} }
@ -282,7 +267,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (cmdparams.Length < 5) if (cmdparams.Length < 5)
{ {
m_log.Error( m_log.Error(
"[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <password> [<save file path>]"); "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]");
return; return;
} }
@ -334,8 +319,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// </summary> /// </summary>
/// <param name="firstName"></param> /// <param name="firstName"></param>
/// <param name="lastName"></param> /// <param name="lastName"></param>
/// <param name="pass">User password</param>
/// <returns></returns> /// <returns></returns>
protected CachedUserInfo GetUserInfo(string firstName, string lastName) protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass)
{ {
CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName);
if (null == userInfo) if (null == userInfo)
@ -346,6 +332,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return null; return null;
} }
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt);
if (userInfo.UserProfile.PasswordHash != md5PasswdHash)
{
m_log.ErrorFormat(
"[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.",
firstName, lastName);
return null;
}
return userInfo; return userInfo;
} }

View File

@ -996,8 +996,6 @@ namespace OpenSim.Region.Framework.Scenes
if (m_frame == Int32.MaxValue) if (m_frame == Int32.MaxValue)
m_frame = 0; m_frame = 0;
otherMS = Environment.TickCount; otherMS = Environment.TickCount;
// run through all entities looking for updates (slow) // run through all entities looking for updates (slow)
if (m_frame % m_update_entities == 0) if (m_frame % m_update_entities == 0)
@ -1017,7 +1015,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.UpdateEntities(); m_sceneGraph.UpdateEntities();
} }
// run through entities that have scheduled themselves for // run through entities that have scheduled themselves for
// updates looking for updates(faster) // updates looking for updates(faster)
if (m_frame % m_update_entitiesquick == 0) if (m_frame % m_update_entitiesquick == 0)