24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-14 22:00:16 +02:00

When the Password attribute is missing in PIEFXIS file, don't check account auth.

This commit is contained in:
Badlop 2010-11-30 23:55:33 +01:00
parent 1b73ac5118
commit 955343f6aa

View File

@ -196,35 +196,44 @@ process_element(El,State) ->
add_user(El, Domain) -> add_user(El, Domain) ->
User = exmpp_xml:get_attribute(El,name,none), User = exmpp_xml:get_attribute(El,name,none),
Password = exmpp_xml:get_attribute(El,password,none), Password = exmpp_xml:get_attribute(El,password,none),
add_user(El, Domain, ?BTL(User), ?BTL(Password)). 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()} %% -> ok | {error, ErrorText::string()}
%% @doc Add a new user to the database. %% @doc Add a new user to the database.
%% If user already exists, it will be only updated. %% If user already exists, it will be only updated.
add_user(El, Domain, User, Password) -> add_user(El, Domain, UserBinary, none) ->
User = ?BTL(UserBinary),
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, UserBinary, PasswordBinary) ->
User = ?BTL(UserBinary),
Password = ?BTL(PasswordBinary),
case create_user(User,Password,Domain) of case create_user(User,Password,Domain) of
ok -> ok ->
ok = exmpp_xml:foreach( populate_user_with_elements(El, Domain, User),
fun(_,Child) ->
populate_user(User,Domain,Child)
end,
El),
ok; ok;
{atomic, exists} -> {atomic, exists} ->
io:format("Account ~s@~s already exists, updating it...~n", io:format("Account ~s@~s already exists, updating it...~n",
[User, Domain]), [User, Domain]),
io:format(""), io:format(""),
ok = exmpp_xml:foreach( populate_user_with_elements(El, Domain, User),
fun(_,Child) -> ok;
populate_user(User,Domain,Child)
end,
El);
{error, Other} -> {error, Other} ->
?ERROR_MSG("Error adding user ~s@~s: ~p~n", [User, Domain, Other]), ?ERROR_MSG("Error adding user ~s@~s: ~p~n", [User, Domain, Other]),
{error, Other} {error, Other}
end. 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()) %% @spec (User::string(), Password::string(), Domain::string())
%% -> ok | {atomic, exists} | {error, not_allowed} %% -> ok | {atomic, exists} | {error, not_allowed}
%% @doc Create a new user %% @doc Create a new user