From 5113d28bb4075b872a8b7a593bcf1cf24ab2c51c Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 28 Jul 2010 19:32:42 +0200 Subject: [PATCH] Return Registered element when account exists (thanks to PioneerMike) --- src/mod_register.erl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mod_register.erl b/src/mod_register.erl index 35fa1ea67..11d4d4959 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -187,6 +187,18 @@ process_iq(From, To, sub_el = [SubEl, ?ERR_BAD_REQUEST]} end; get -> + {UsernameSubels, QuerySubels} = + case From of + #jid{user = User, lserver = Server} -> + case ejabberd_auth:is_user_exists(User,Server) of + true -> + {[{xmlcdata, User}], [{xmlelement, "registered", [], []}]}; + false -> + {[{xmlcdata, User}], []} + end; + _ -> + {[], []} + end, IQ#iq{type = result, sub_el = [{xmlelement, "query", @@ -197,8 +209,9 @@ process_iq(From, To, Lang, "Choose a username and password " "to register with this server")}]}, - {xmlelement, "username", [], []}, - {xmlelement, "password", [], []}]}]} + {xmlelement, "username", [], UsernameSubels}, + {xmlelement, "password", [], []} + | QuerySubels]}]} end. %% @doc Try to change password and return IQ response