Commit c22240a1 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Minor work.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3695 b35dd754-fafc-0310-a699-88a17e54d16e
parent 342061ef
...@@ -14,6 +14,8 @@ package org.jivesoftware.wildfire.handler; ...@@ -14,6 +14,8 @@ package org.jivesoftware.wildfire.handler;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.*; import org.jivesoftware.wildfire.*;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.disco.ServerFeaturesProvider; import org.jivesoftware.wildfire.disco.ServerFeaturesProvider;
...@@ -27,8 +29,6 @@ import org.jivesoftware.wildfire.user.User; ...@@ -27,8 +29,6 @@ import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserAlreadyExistsException; import org.jivesoftware.wildfire.user.UserAlreadyExistsException;
import org.jivesoftware.wildfire.user.UserManager; import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException; import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
...@@ -237,12 +237,12 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -237,12 +237,12 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
} }
} }
else { else {
String username = null; String username;
String password = null; String password = null;
String email = null; String email = null;
String name = null; String name = null;
User newUser = null; User newUser;
XDataFormImpl registrationForm = null; XDataFormImpl registrationForm;
FormField field; FormField field;
Element formElement = iqElement.element("x"); Element formElement = iqElement.element("x");
...@@ -308,23 +308,18 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -308,23 +308,18 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
} }
else { else {
User user = userManager.getUser(session.getUsername()); User user = userManager.getUser(session.getUsername());
if (user != null) { if (user.getUsername().equalsIgnoreCase(username)) {
if (user.getUsername().equalsIgnoreCase(username)) { if (password != null && password.trim().length() > 0) {
if (password != null && password.trim().length() > 0) { user.setPassword(password);
user.setPassword(password);
}
if (!onlyPassword) {
user.setEmail(email);
}
newUser = user;
} }
else { if (!onlyPassword) {
// An admin can create new accounts when logged in. user.setEmail(email);
newUser = userManager.createUser(username, password, null, email);
} }
newUser = user;
} }
else { else {
throw new UnauthorizedException(); // An admin can create new accounts when logged in.
newUser = userManager.createUser(username, password, null, email);
} }
} }
} }
...@@ -380,7 +375,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -380,7 +375,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
reply.setError(PacketError.Condition.not_allowed); reply.setError(PacketError.Condition.not_allowed);
} }
catch (Exception e) { catch (Exception e) {
// Some unexpected error happened so return an internal_server_error // Some unexpected error happened so return an internal_server_error
reply = IQ.createResultIQ(packet); reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy()); reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.internal_server_error); reply.setError(PacketError.Condition.internal_server_error);
...@@ -416,8 +411,8 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid ...@@ -416,8 +411,8 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
return info; return info;
} }
public Iterator getFeatures() { public Iterator<String> getFeatures() {
ArrayList features = new ArrayList(); ArrayList<String> features = new ArrayList<String>();
features.add("jabber:iq:register"); features.add("jabber:iq:register");
return features.iterator(); return features.iterator();
} }
......
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