aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-02-18 15:50:18 +0000
committerJustin Clarke Casey2008-02-18 15:50:18 +0000
commit500d259c252f8c4f75c6f37e1067d57811426ddd (patch)
tree778ae131f7fdb01678f82cf8b94a25992e722390 /OpenSim
parenta new attempt at converting to the right types (diff)
downloadopensim-SC_OLD-500d259c252f8c4f75c6f37e1067d57811426ddd.zip
opensim-SC_OLD-500d259c252f8c4f75c6f37e1067d57811426ddd.tar.gz
opensim-SC_OLD-500d259c252f8c4f75c6f37e1067d57811426ddd.tar.bz2
opensim-SC_OLD-500d259c252f8c4f75c6f37e1067d57811426ddd.tar.xz
* Do not allow a user to be created if one with the same name already exists
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs20
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs45
-rw-r--r--OpenSim/Framework/Console/ConsoleBase.cs8
-rw-r--r--OpenSim/Framework/IUserService.cs16
-rw-r--r--OpenSim/Grid/UserServer/Main.cs23
5 files changed, 69 insertions, 43 deletions
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
131 regY = Convert.ToUInt32(cmmdParams[5]); 131 regY = Convert.ToUInt32(cmmdParams[5]);
132 } 132 }
133 133
134 AddUser(firstName, lastName, password, regX, regY); 134 if (null == m_userService.GetUserProfile(firstName, lastName))
135 {
136 AddUser(firstName, lastName, password, regX, regY);
137 }
138 else
139 {
140 m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
141 }
135 break; 142 break;
136 } 143 }
137 } 144 }
138 145
146 /// <summary>
147 /// Persistently adds a user to OpenSim.
148 /// </summary>
149 /// <param name="firstName"></param>
150 /// <param name="lastName"></param>
151 /// <param name="password"></param>
152 /// <param name="regX"></param>
153 /// <param name="regY"></param>
154 /// <returns>The UUID of the added user. Returns null if the add was unsuccessful</returns>
139 public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY) 155 public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
140 { 156 {
141 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty); 157 string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
@@ -149,7 +165,7 @@ namespace OpenSim.Framework.Communications
149 else 165 else
150 { 166 {
151 m_inventoryService.CreateNewUserInventory(userProf.UUID); 167 m_inventoryService.CreateNewUserInventory(userProf.UUID);
152 System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName); 168 System.Console.WriteLine("[USERS]: Created new inventory set for " + firstName + " " + lastName);
153 return userProf.UUID; 169 return userProf.UUID;
154 } 170 }
155 } 171 }
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
86 86
87 #region Get UserProfile 87 #region Get UserProfile
88 88
89 /// <summary> 89 // see IUserService
90 /// Loads a user profile from a database by UUID 90 public UserProfileData GetUserProfile(string fname, string lname)
91 /// </summary> 91 {
92 /// <param name="uuid">The target UUID</param> 92 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
93 /// <returns>A user profile. Returns null if no user profile is found.</returns> 93 {
94 UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
95
96 if (profile != null)
97 {
98 profile.currentAgent = getUserAgent(profile.UUID);
99 return profile;
100 }
101 }
102
103 return null;
104 }
105
106 // see IUserService
94 public UserProfileData GetUserProfile(LLUUID uuid) 107 public UserProfileData GetUserProfile(LLUUID uuid)
95 { 108 {
96 foreach (KeyValuePair<string, IUserData> plugin in _plugins) 109 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
@@ -126,28 +139,6 @@ namespace OpenSim.Framework.UserManagement
126 } 139 }
127 140
128 /// <summary> 141 /// <summary>
129 /// Loads a user profile by name
130 /// </summary>
131 /// <param name="fname">First name</param>
132 /// <param name="lname">Last name</param>
133 /// <returns>A user profile. Returns null if no profile is found</returns>
134 public UserProfileData GetUserProfile(string fname, string lname)
135 {
136 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
137 {
138 UserProfileData profile = plugin.Value.GetUserByName(fname, lname);
139
140 if (profile != null)
141 {
142 profile.currentAgent = getUserAgent(profile.UUID);
143 return profile;
144 }
145 }
146
147 return null;
148 }
149
150 /// <summary>
151 /// Set's user profile from object 142 /// Set's user profile from object
152 /// </summary> 143 /// </summary>
153 /// <param name="fname">First name</param> 144 /// <param name="fname">First name</param>
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
295 } 295 }
296 296
297 // Displays a prompt and waits for the user to enter a string, then returns that string 297 // Displays a prompt and waits for the user to enter a string, then returns that string
298 // Done with no echo and suitable for passwords 298 // (Done with no echo and suitable for passwords - currently disabled)
299 public string PasswdPrompt(string prompt) 299 public string PasswdPrompt(string prompt)
300 { 300 {
301 // FIXME: Needs to be better abstracted 301 // FIXME: Needs to be better abstracted
302 System.Console.WriteLine(String.Format("{0}: ", prompt)); 302 System.Console.WriteLine(String.Format("{0}: ", prompt));
303 ConsoleColor oldfg = System.Console.ForegroundColor; 303 //ConsoleColor oldfg = System.Console.ForegroundColor;
304 System.Console.ForegroundColor = System.Console.BackgroundColor; 304 //System.Console.ForegroundColor = System.Console.BackgroundColor;
305 string temp = System.Console.ReadLine(); 305 string temp = System.Console.ReadLine();
306 System.Console.ForegroundColor = oldfg; 306 //System.Console.ForegroundColor = oldfg;
307 return temp; 307 return temp;
308 } 308 }
309 309
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
32{ 32{
33 public interface IUserService 33 public interface IUserService
34 { 34 {
35 /// <summary>
36 /// Loads a user profile by name
37 /// </summary>
38 /// <param name="fname">First name</param>
39 /// <param name="lname">Last name</param>
40 /// <returns>A user profile. Returns null if no profile is found</returns>
35 UserProfileData GetUserProfile(string firstName, string lastName); 41 UserProfileData GetUserProfile(string firstName, string lastName);
42
36 //UserProfileData GetUserProfile(string name); 43 //UserProfileData GetUserProfile(string name);
44
45 /// <summary>
46 /// Loads a user profile from a database by UUID
47 /// </summary>
48 /// <param name="uuid">The target UUID</param>
49 /// <returns>A user profile. Returns null if no user profile is found.</returns>
37 UserProfileData GetUserProfile(LLUUID userId); 50 UserProfileData GetUserProfile(LLUUID userId);
51
38 void clearUserAgent(LLUUID avatarID); 52 void clearUserAgent(LLUUID avatarID);
39 List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query); 53 List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(LLUUID QueryID, string Query);
40 54
@@ -88,4 +102,4 @@ namespace OpenSim.Framework
88 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param> 102 /// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
89 List<FriendListItem> GetUserFriendList(LLUUID friendlistowner); 103 List<FriendListItem> GetUserFriendList(LLUUID friendlistowner);
90 } 104 }
91} \ No newline at end of file 105}
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 8c05d86..3500665 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -148,6 +148,12 @@ namespace OpenSim.Grid.UserServer
148 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); 148 regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
149 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); 149 regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
150 150
151 if (null != m_userManager.GetUserProfile(tempfirstname, templastname))
152 {
153 m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
154 break;
155 }
156
151 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); 157 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
152 158
153 LLUUID userID = new LLUUID(); 159 LLUUID userID = new LLUUID();
@@ -157,7 +163,7 @@ namespace OpenSim.Grid.UserServer
157 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); 163 m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
158 } catch (Exception ex) 164 } catch (Exception ex)
159 { 165 {
160 m_log.ErrorFormat("[SERVER]: Error creating user: {0}", ex.ToString()); 166 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
161 } 167 }
162 168
163 try 169 try
@@ -167,7 +173,7 @@ namespace OpenSim.Grid.UserServer
167 } 173 }
168 catch (Exception ex) 174 catch (Exception ex)
169 { 175 {
170 m_log.ErrorFormat("[SERVER]: Error creating inventory for user: {0}", ex.ToString()); 176 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", ex.ToString());
171 } 177 }
172 m_lastCreatedUser = userID; 178 m_lastCreatedUser = userID;
173 break; 179 break;
@@ -204,13 +210,12 @@ namespace OpenSim.Grid.UserServer
204 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); 210 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
205 // requester.ReturnResponseVal = TestResponse; 211 // requester.ReturnResponseVal = TestResponse;
206 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); 212 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
207 List<InventoryFolderBase> folders = 213 SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
208 SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", 214 m_userManager.
209 m_userManager. 215 _config.
210 _config. 216 InventoryUrl +
211 InventoryUrl + 217 "RootFolders/",
212 "RootFolders/", 218 m_lastCreatedUser);
213 m_lastCreatedUser);
214 break; 219 break;
215 } 220 }
216 } 221 }