Commit b6b3829c authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added registration field "name". JM-85


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@724 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3acba09c
...@@ -92,6 +92,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -92,6 +92,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
probeResult.addElement("username"); probeResult.addElement("username");
probeResult.addElement("password"); probeResult.addElement("password");
probeResult.addElement("email"); probeResult.addElement("email");
probeResult.addElement("name");
// Create the registration form to include in the probeResult. The form will include // Create the registration form to include in the probeResult. The form will include
// the basic information plus name and visibility of name and email. // the basic information plus name and visibility of name and email.
...@@ -161,7 +162,8 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -161,7 +162,8 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
currentRegistration.element("username").setText(user.getUsername()); currentRegistration.element("username").setText(user.getUsername());
currentRegistration.element("password").setText(""); currentRegistration.element("password").setText("");
currentRegistration.element("email").setText(user.getEmail()); currentRegistration.element("email").setText(user.getEmail());
currentRegistration.element("name").setText(user.getName());
Element form = currentRegistration.element(QName.get("x", "jabber:x:data")); Element form = currentRegistration.element(QName.get("x", "jabber:x:data"));
Iterator fields = form.elementIterator("field"); Iterator fields = form.elementIterator("field");
Element field; Element field;
...@@ -220,6 +222,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -220,6 +222,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
String username = null; String username = null;
String password = null; String password = null;
String email = null; String email = null;
String name = null;
User newUser = null; User newUser = null;
XDataFormImpl registrationForm = null; XDataFormImpl registrationForm = null;
FormField field; FormField field;
...@@ -245,12 +248,19 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -245,12 +248,19 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
values = field.getValues(); values = field.getValues();
email = (values.hasNext() ? values.next() : " "); email = (values.hasNext() ? values.next() : " ");
} }
// Get the name sent in the form
field = registrationForm.getField("name");
if (field != null) {
values = field.getValues();
name = (values.hasNext() ? values.next() : " ");
}
} }
else { else {
// Get the registration info from the query elements // Get the registration info from the query elements
username = iqElement.elementText("username"); username = iqElement.elementText("username");
password = iqElement.elementText("password"); password = iqElement.elementText("password");
email = iqElement.elementText("email"); email = iqElement.elementText("email");
name = iqElement.elementText("name");
} }
if (email == null || "".equals(email)) { if (email == null || "".equals(email)) {
email = " "; email = " ";
...@@ -285,15 +295,8 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -285,15 +295,8 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
newUser = userManager.createUser(username, password, null, email); newUser = userManager.createUser(username, password, null, email);
} }
// Set and save the extra user info (e.g. full name, etc.) // Set and save the extra user info (e.g. full name, etc.)
if (newUser != null && registrationForm != null) { if (newUser != null && name != null) {
Iterator<String> values; newUser.setName(name);
// Get the full name sent in the form
field = registrationForm.getField("name");
if (field != null) {
values = field.getValues();
String name = (values.hasNext() ? values.next() : " ");
newUser.setName(name);
}
} }
reply = IQ.createResultIQ(packet); reply = IQ.createResultIQ(packet);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment