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 +++++++++------------- 2 files changed, 36 insertions(+), 29 deletions(-) (limited to 'OpenSim/Framework/Communications') 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 -- cgit v1.1