From 500d259c252f8c4f75c6f37e1067d57811426ddd Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 18 Feb 2008 15:50:18 +0000 Subject: * Do not allow a user to be created if one with the same name already exists --- .../Communications/CommunicationsManager.cs | 20 +++++++++- .../Framework/Communications/UserManagerBase.cs | 45 +++++++++------------- OpenSim/Framework/Console/ConsoleBase.cs | 8 ++-- OpenSim/Framework/IUserService.cs | 16 +++++++- 4 files changed, 55 insertions(+), 34 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index eb820c1..4ad808a 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -131,11 +131,27 @@ namespace OpenSim.Framework.Communications 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; } } + /// + /// Persistently adds a user to OpenSim. + /// + /// + /// + /// + /// + /// + /// The UUID of the added user. Returns null if the add was unsuccessful 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; } } diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index dbf9276..733d62b 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -86,11 +86,24 @@ namespace OpenSim.Framework.UserManagement #region Get UserProfile - /// - /// Loads a user profile from a database by UUID - /// - /// The target UUID - /// A user profile. Returns null if no user profile is found. + // see IUserService + public UserProfileData GetUserProfile(string fname, string lname) + { + foreach (KeyValuePair 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 plugin in _plugins) @@ -126,28 +139,6 @@ namespace OpenSim.Framework.UserManagement } /// - /// Loads a user profile by name - /// - /// First name - /// Last name - /// A user profile. Returns null if no profile is found - public UserProfileData GetUserProfile(string fname, string lname) - { - foreach (KeyValuePair plugin in _plugins) - { - UserProfileData profile = plugin.Value.GetUserByName(fname, lname); - - if (profile != null) - { - profile.currentAgent = getUserAgent(profile.UUID); - return profile; - } - } - - return null; - } - - /// /// Set's user profile from object /// /// First name diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 829d6c7..63711f3 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -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; } diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index f1f3c81..3b84486 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -32,9 +32,23 @@ namespace OpenSim.Framework { public interface IUserService { + /// + /// Loads a user profile by name + /// + /// First name + /// Last name + /// A user profile. Returns null if no profile is found UserProfileData GetUserProfile(string firstName, string lastName); + //UserProfileData GetUserProfile(string name); + + /// + /// Loads a user profile from a database by UUID + /// + /// The target UUID + /// A user profile. Returns null if no user profile is found. UserProfileData GetUserProfile(LLUUID userId); + void clearUserAgent(LLUUID avatarID); List GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); @@ -88,4 +102,4 @@ namespace OpenSim.Framework /// The agent that we're retreiving the friends Data. List GetUserFriendList(LLUUID friendlistowner); } -} \ No newline at end of file +} -- cgit v1.1