aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer/Main.cs')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs141
1 files changed, 85 insertions, 56 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 1a37b83..eb47259 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -162,62 +162,12 @@ namespace OpenSim.Grid.UserServer
162 m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile); 162 m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
163 } 163 }
164 164
165 public void do_create(string what) 165 public void do_create(string[] args)
166 { 166 {
167 switch (what) 167 switch (args[0])
168 { 168 {
169 case "user": 169 case "user":
170 string tempfirstname = m_console.CmdPrompt("First name"); 170 CreateUser(args);
171 string templastname = m_console.CmdPrompt("Last name");
172 //tempMD5Passwd = m_console.PasswdPrompt("Password");
173 string tempMD5Passwd = m_console.CmdPrompt("Password");
174 uint regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
175 uint regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
176
177 if (null != m_userManager.GetUserProfile(tempfirstname, templastname))
178 {
179 m_log.ErrorFormat(
180 "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
181
182 break;
183 }
184
185 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
186
187 UUID userID = new UUID();
188
189 try
190 {
191 userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
192 }
193 catch (Exception ex)
194 {
195 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
196 }
197
198 try
199 {
200 if (!m_interServiceInventoryService.CreateNewUserInventory(userID))
201 {
202 throw new Exception(
203 String.Format(
204 "The inventory creation request for user {0} did not succeed."
205 + " Please contact your inventory service provider for more information.",
206 userID));
207 }
208 }
209 catch (WebException)
210 {
211 m_log.ErrorFormat(
212 "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}",
213 Cfg.InventoryUrl + "CreateInventory/", userID);
214 }
215 catch (Exception e)
216 {
217 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e);
218 }
219
220 m_lastCreatedUser = userID;
221 break; 171 break;
222 } 172 }
223 } 173 }
@@ -244,8 +194,87 @@ namespace OpenSim.Grid.UserServer
244 194
245 break; 195 break;
246 } 196 }
247 } 197 }
248 198
199 /// <summary>
200 /// Create a new user
201 /// </summary>
202 /// <param name="cmdparams">string array with parameters: firstname, lastname, password, locationX, locationY, email</param>
203 protected void CreateUser(string[] cmdparams)
204 {
205 string firstName;
206 string lastName;
207 string password;
208 string email;
209 uint regX = 1000;
210 uint regY = 1000;
211
212 if (cmdparams.Length < 2)
213 firstName = MainConsole.Instance.CmdPrompt("First name", "Default");
214 else firstName = cmdparams[1];
215
216 if (cmdparams.Length < 3)
217 lastName = MainConsole.Instance.CmdPrompt("Last name", "User");
218 else lastName = cmdparams[2];
219
220 if (cmdparams.Length < 4)
221 password = MainConsole.Instance.PasswdPrompt("Password");
222 else password = cmdparams[3];
223
224 if (cmdparams.Length < 5)
225 regX = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region X", regX.ToString()));
226 else regX = Convert.ToUInt32(cmdparams[4]);
227
228 if (cmdparams.Length < 6)
229 regY = Convert.ToUInt32(MainConsole.Instance.CmdPrompt("Start Region Y", regY.ToString()));
230 else regY = Convert.ToUInt32(cmdparams[5]);
231
232 if (cmdparams.Length < 7)
233 email = MainConsole.Instance.CmdPrompt("Email", "");
234 else email = cmdparams[6];
235
236 if (null == m_userManager.GetUserProfile(firstName, lastName))
237 {
238 password = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);
239
240 UUID userID = new UUID();
241
242 try
243 {
244 userID = m_userManager.AddUserProfile(firstName, lastName, password, email, regX, regY);
245 }
246 catch (Exception ex)
247 {
248 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
249 }
250
251 try
252 {
253 if (!m_interServiceInventoryService.CreateNewUserInventory(userID))
254 {
255 throw new Exception(
256 String.Format("The inventory creation request for user {0} did not succeed."
257 + " Please contact your inventory service provider for more information.", userID));
258 }
259 }
260 catch (WebException)
261 {
262 m_log.ErrorFormat("[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}",
263 Cfg.InventoryUrl + "CreateInventory/", userID);
264 }
265 catch (Exception e)
266 {
267 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e);
268 }
269
270 m_lastCreatedUser = userID;
271 }
272 else
273 {
274 m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", firstName, lastName);
275 }
276 }
277
249 /// <summary> 278 /// <summary>
250 /// Reset a user password. 279 /// Reset a user password.
251 /// </summary> 280 /// </summary>
@@ -277,7 +306,7 @@ namespace OpenSim.Grid.UserServer
277 switch (cmd) 306 switch (cmd)
278 { 307 {
279 case "create": 308 case "create":
280 do_create(cmdparams[0]); 309 do_create(cmdparams);
281 break; 310 break;
282 311
283 case "reset": 312 case "reset":