* Do not allow a user to be created if one with the same name already exists
parent
28c808446d
commit
500d259c25
|
@ -131,11 +131,27 @@ namespace OpenSim.Framework.Communications
|
|||
regY = Convert.ToUInt32(cmmdParams[5]);
|
||||
}
|
||||
|
||||
if (null == m_userService.GetUserProfile(firstName, lastName))
|
||||
{
|
||||
AddUser(firstName, lastName, password, regX, regY);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Persistently adds a user to OpenSim.
|
||||
/// </summary>
|
||||
/// <param name="firstName"></param>
|
||||
/// <param name="lastName"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <param name="regX"></param>
|
||||
/// <param name="regY"></param>
|
||||
/// <returns>The UUID of the added user. Returns null if the add was unsuccessful</returns>
|
||||
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
|
||||
{
|
||||
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
|
||||
|
@ -149,7 +165,7 @@ namespace OpenSim.Framework.Communications
|
|||
else
|
||||
{
|
||||
m_inventoryService.CreateNewUserInventory(userProf.UUID);
|
||||
System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName);
|
||||
System.Console.WriteLine("[USERS]: Created new inventory set for " + firstName + " " + lastName);
|
||||
return userProf.UUID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,11 +86,24 @@ namespace OpenSim.Framework.UserManagement
|
|||
|
||||
#region Get UserProfile
|
||||
|
||||
/// <summary>
|
||||
/// Loads a user profile from a database by UUID
|
||||
/// </summary>
|
||||
/// <param name="uuid">The target UUID</param>
|
||||
/// <returns>A user profile. Returns null if no user profile is found.</returns>
|
||||
// see IUserService
|
||||
public UserProfileData GetUserProfile(string fname, string lname)
|
||||
{
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
{
|
||||
UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
profile.currentAgent = getUserAgent(profile.UUID);
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// see IUserService
|
||||
public UserProfileData GetUserProfile(LLUUID uuid)
|
||||
{
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
|
@ -125,28 +138,6 @@ namespace OpenSim.Framework.UserManagement
|
|||
return pickerlist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a user profile by name
|
||||
/// </summary>
|
||||
/// <param name="fname">First name</param>
|
||||
/// <param name="lname">Last name</param>
|
||||
/// <returns>A user profile. Returns null if no profile is found</returns>
|
||||
public UserProfileData GetUserProfile(string fname, string lname)
|
||||
{
|
||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||
{
|
||||
UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
|
||||
|
||||
if (profile != null)
|
||||
{
|
||||
profile.currentAgent = getUserAgent(profile.UUID);
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set's user profile from object
|
||||
/// </summary>
|
||||
|
|
|
@ -295,15 +295,15 @@ namespace OpenSim.Framework.Console
|
|||
}
|
||||
|
||||
// Displays a prompt and waits for the user to enter a string, then returns that string
|
||||
// Done with no echo and suitable for passwords
|
||||
// (Done with no echo and suitable for passwords - currently disabled)
|
||||
public string PasswdPrompt(string prompt)
|
||||
{
|
||||
// FIXME: Needs to be better abstracted
|
||||
System.Console.WriteLine(String.Format("{0}: ", prompt));
|
||||
ConsoleColor oldfg = System.Console.ForegroundColor;
|
||||
System.Console.ForegroundColor = System.Console.BackgroundColor;
|
||||
//ConsoleColor oldfg = System.Console.ForegroundColor;
|
||||
//System.Console.ForegroundColor = System.Console.BackgroundColor;
|
||||
string temp = System.Console.ReadLine();
|
||||
System.Console.ForegroundColor = oldfg;
|
||||
//System.Console.ForegroundColor = oldfg;
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,23 @@ namespace OpenSim.Framework
|
|||
{
|
||||
public interface IUserService
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads a user profile by name
|
||||
/// </summary>
|
||||
/// <param name="fname">First name</param>
|
||||
/// <param name="lname">Last name</param>
|
||||
/// <returns>A user profile. Returns null if no profile is found</returns>
|
||||
UserProfileData GetUserProfile(string firstName, string lastName);
|
||||
|
||||
//UserProfileData GetUserProfile(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Loads a user profile from a database by UUID
|
||||
/// </summary>
|
||||
/// <param name="uuid">The target UUID</param>
|
||||
/// <returns>A user profile. Returns null if no user profile is found.</returns>
|
||||
UserProfileData GetUserProfile(LLUUID userId);
|
||||
|
||||
void clearUserAgent(LLUUID avatarID);
|
||||
List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
|
||||
|
||||
|
|
|
@ -148,6 +148,12 @@ namespace OpenSim.Grid.UserServer
|
|||
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
|
||||
regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
|
||||
|
||||
if (null != m_userManager.GetUserProfile(tempfirstname, templastname))
|
||||
{
|
||||
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
|
||||
break;
|
||||
}
|
||||
|
||||
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
|
||||
|
||||
LLUUID userID = new LLUUID();
|
||||
|
@ -157,7 +163,7 @@ namespace OpenSim.Grid.UserServer
|
|||
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
m_log.ErrorFormat("[SERVER]: Error creating user: {0}", ex.ToString());
|
||||
m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -167,7 +173,7 @@ namespace OpenSim.Grid.UserServer
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.ErrorFormat("[SERVER]: Error creating inventory for user: {0}", ex.ToString());
|
||||
m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", ex.ToString());
|
||||
}
|
||||
m_lastCreatedUser = userID;
|
||||
break;
|
||||
|
@ -204,7 +210,6 @@ namespace OpenSim.Grid.UserServer
|
|||
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
|
||||
// requester.ReturnResponseVal = TestResponse;
|
||||
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
||||
List<InventoryFolderBase> folders =
|
||||
SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
|
||||
m_userManager.
|
||||
_config.
|
||||
|
|
Loading…
Reference in New Issue