From b8f04aae6fc92f0ee19a3c83bb2433153f941dbe Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 1 Dec 2010 00:34:48 +0100 Subject: [PATCH] When the Password attribute is missing in PIEFXIS file, don't check account auth. --- src/ejabberd_piefxis.erl | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl index ecfadb14f..5bb4f25eb 100644 --- a/src/ejabberd_piefxis.erl +++ b/src/ejabberd_piefxis.erl @@ -162,33 +162,39 @@ add_user(El, Domain) -> Password = exmpp_xml:get_attribute(El,<<"password">>,none), add_user(El, Domain, User, Password). -%% @spec (El::xmlel(), Domain::string(), User::string(), Password::string()) +%% @spec (El::xmlel(), Domain::string(), User::binary(), Password::binary() | none) %% -> ok | {error, ErrorText::string()} %% @doc Add a new user to the database. %% If user already exists, it will be only updated. +add_user(El, Domain, User, none) -> + io:format("Account ~s@~s will not be created, updating it...~n", + [User, Domain]), + io:format(""), + populate_user_with_elements(El, Domain, User), + ok; add_user(El, Domain, User, Password) -> case create_user(User,Password,Domain) of ok -> - ok = exmpp_xml:foreach( - fun(_,Child) -> - populate_user(User,Domain,Child) - end, - El), + populate_user_with_elements(El, Domain, User), ok; {atomic, exists} -> io:format("Account ~s@~s already exists, updating it...~n", [User, Domain]), io:format(""), - ok = exmpp_xml:foreach( - fun(_,Child) -> - populate_user(User,Domain,Child) - end, - El); + populate_user_with_elements(El, Domain, User), + ok; {error, Other} -> ?ERROR_MSG("Error adding user ~s@~s: ~p~n", [User, Domain, Other]), {error, Other} end. +populate_user_with_elements(El, Domain, User) -> + exmpp_xml:foreach( + fun (_,Child) -> + populate_user(User,Domain,Child) + end, + El). + %% @spec (User::string(), Password::string(), Domain::string()) %% -> ok | {atomic, exists} | {error, not_allowed} %% @doc Create a new user