* 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]);
|
regY = Convert.ToUInt32(cmmdParams[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddUser(firstName, lastName, password, regX, regY);
|
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;
|
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)
|
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
|
||||||
{
|
{
|
||||||
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
|
||||||
|
@ -149,7 +165,7 @@ namespace OpenSim.Framework.Communications
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_inventoryService.CreateNewUserInventory(userProf.UUID);
|
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;
|
return userProf.UUID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,11 +86,24 @@ namespace OpenSim.Framework.UserManagement
|
||||||
|
|
||||||
#region Get UserProfile
|
#region Get UserProfile
|
||||||
|
|
||||||
/// <summary>
|
// see IUserService
|
||||||
/// Loads a user profile from a database by UUID
|
public UserProfileData GetUserProfile(string fname, string lname)
|
||||||
/// </summary>
|
{
|
||||||
/// <param name="uuid">The target UUID</param>
|
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||||
/// <returns>A user profile. Returns null if no user profile is found.</returns>
|
{
|
||||||
|
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)
|
public UserProfileData GetUserProfile(LLUUID uuid)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
foreach (KeyValuePair<string, IUserData> plugin in _plugins)
|
||||||
|
@ -125,28 +138,6 @@ namespace OpenSim.Framework.UserManagement
|
||||||
return pickerlist;
|
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>
|
/// <summary>
|
||||||
/// Set's user profile from object
|
/// Set's user profile from object
|
||||||
/// </summary>
|
/// </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
|
// 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)
|
public string PasswdPrompt(string prompt)
|
||||||
{
|
{
|
||||||
// FIXME: Needs to be better abstracted
|
// FIXME: Needs to be better abstracted
|
||||||
System.Console.WriteLine(String.Format("{0}: ", prompt));
|
System.Console.WriteLine(String.Format("{0}: ", prompt));
|
||||||
ConsoleColor oldfg = System.Console.ForegroundColor;
|
//ConsoleColor oldfg = System.Console.ForegroundColor;
|
||||||
System.Console.ForegroundColor = System.Console.BackgroundColor;
|
//System.Console.ForegroundColor = System.Console.BackgroundColor;
|
||||||
string temp = System.Console.ReadLine();
|
string temp = System.Console.ReadLine();
|
||||||
System.Console.ForegroundColor = oldfg;
|
//System.Console.ForegroundColor = oldfg;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,23 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
public interface IUserService
|
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 firstName, string lastName);
|
||||||
|
|
||||||
//UserProfileData GetUserProfile(string name);
|
//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);
|
UserProfileData GetUserProfile(LLUUID userId);
|
||||||
|
|
||||||
void clearUserAgent(LLUUID avatarID);
|
void clearUserAgent(LLUUID avatarID);
|
||||||
List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
|
List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,12 @@ namespace OpenSim.Grid.UserServer
|
||||||
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
|
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
|
||||||
regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
|
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);
|
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
|
||||||
|
|
||||||
LLUUID userID = new LLUUID();
|
LLUUID userID = new LLUUID();
|
||||||
|
@ -157,7 +163,7 @@ namespace OpenSim.Grid.UserServer
|
||||||
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
|
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
|
||||||
} catch (Exception ex)
|
} catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("[SERVER]: Error creating user: {0}", ex.ToString());
|
m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -167,7 +173,7 @@ namespace OpenSim.Grid.UserServer
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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;
|
m_lastCreatedUser = userID;
|
||||||
break;
|
break;
|
||||||
|
@ -204,13 +210,12 @@ namespace OpenSim.Grid.UserServer
|
||||||
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
|
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
|
||||||
// requester.ReturnResponseVal = TestResponse;
|
// requester.ReturnResponseVal = TestResponse;
|
||||||
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
|
||||||
List<InventoryFolderBase> folders =
|
SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
|
||||||
SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
|
m_userManager.
|
||||||
m_userManager.
|
_config.
|
||||||
_config.
|
InventoryUrl +
|
||||||
InventoryUrl +
|
"RootFolders/",
|
||||||
"RootFolders/",
|
m_lastCreatedUser);
|
||||||
m_lastCreatedUser);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue