25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Added a comment to improve code as suggested by Dialyzer.

SVN Revision: 2871
This commit is contained in:
Mickaël Rémond 2010-01-09 16:38:07 +00:00
parent 4fba4db32f
commit 7ed6614ad4

View File

@ -137,7 +137,7 @@ check_password_with_authmodule(User, Server, Password)
%% AuthModule = authmodule() %% AuthModule = authmodule()
%% @doc Check the password is valid and also return the authentication module that accepts it. %% @doc Check the password is valid and also return the authentication module that accepts it.
%% The password is 'undefined' if the client %% The password is 'undefined' if the client
%% authenticates using the digest method as defined in %% authenticates using the digest method as defined in
%% XEP-0078: Non-SASL Authentication %% XEP-0078: Non-SASL Authentication
check_password_with_authmodule(User, Server, Password, Digest, DigestGen) check_password_with_authmodule(User, Server, Password, Digest, DigestGen)
@ -161,7 +161,6 @@ check_password_loop([AuthModule | AuthModules], Args) ->
%% Server = string() %% Server = string()
%% Password = string() %% Password = string()
%% ErrorType = empty_password | not_allowed | invalid_jid %% ErrorType = empty_password | not_allowed | invalid_jid
set_password(_User, _Server, "") -> set_password(_User, _Server, "") ->
%% We do not allow empty password %% We do not allow empty password
{error, empty_password}; {error, empty_password};
@ -178,36 +177,36 @@ set_password(User, Server, Password)
%% User = string() %% User = string()
%% Server = string() %% Server = string()
%% Password = string() | nil() %% Password = string() | nil()
try_register(_User, _Server, "") -> try_register(_User, _Server, "") ->
%% We do not allow empty password %% We do not allow empty password
{error, not_allowed}; {error, not_allowed};
try_register(User, Server, Password) try_register(User, Server, Password)
when is_list(User), is_list(Server), is_list(Password) -> when is_list(User), is_list(Server), is_list(Password) ->
case is_user_exists(User,Server) of case is_user_exists(User, Server) of
true -> true ->
{atomic, exists}; {atomic, exists};
false -> false ->
case lists:member(exmpp_stringprep:nameprep(Server), ?MYHOSTS) of case lists:member(exmpp_stringprep:nameprep(Server), ?MYHOSTS) of
true -> true ->
Res = lists:foldl( Res = lists:foldl(
fun(_M, {atomic, ok} = Res) -> fun (_M, {atomic, ok} = Res) ->
Res; Res;
(M, _) -> (M, _) ->
M:try_register(User, Server, Password) M:try_register(User, Server, Password)
end, {error, not_allowed}, auth_modules(Server)), end, {error, not_allowed}, auth_modules(Server)),
case Res of trigger_register_hooks(Res, User, Server);
{atomic, ok} ->
ejabberd_hooks:run(register_user, list_to_binary(Server),
[User, Server]),
{atomic, ok};
_ -> Res
end;
false -> false ->
{error, not_allowed} {error, not_allowed}
end end
end. end.
trigger_register_hooks({atomic, ok} = Res, User, Server) ->
ejabberd_hooks:run(register_user, list_to_binary(Server),
[User, Server]),
Res;
trigger_register_hooks(Res, _User, _Server) ->
Res.
%% @spec () -> [{LUser, LServer}] %% @spec () -> [{LUser, LServer}]
%% LUser = string() %% LUser = string()
%% LServer = string() %% LServer = string()
@ -376,17 +375,19 @@ is_user_exists_in_other_modules_loop([AuthModule|AuthModules], User, Server) ->
%% User = string() %% User = string()
%% Server = string() %% Server = string()
%% @doc Remove user. %% @doc Remove user.
%% Note: it may return ok even if there was some problem removing the user. %% TODO: Fix me: It always return ok even if there was some problem removing the user.
%% dialyzer warning
%% ejabberd_auth.erl:388: The variable _ can never match since previous clauses completely covered the type 'ok'
remove_user(User, Server) when is_list(User), is_list(Server) -> remove_user(User, Server) when is_list(User), is_list(Server) ->
R = lists:foreach( R = lists:foreach(
fun(M) -> fun(M) ->
M:remove_user(User, Server) M:remove_user(User, Server)
end, auth_modules(Server)), end, auth_modules(Server)),
case R of case R of
ok -> ejabberd_hooks:run(remove_user, list_to_binary(exmpp_stringprep:nameprep(Server)), ok -> ejabberd_hooks:run(remove_user, list_to_binary(exmpp_stringprep:nameprep(Server)),
[list_to_binary(User), list_to_binary(Server)]); [list_to_binary(User), list_to_binary(Server)]);
_ -> none _ -> none
end, end,
R. R.
@ -408,7 +409,7 @@ remove_user(User, Server, Password)
M:remove_user(User, Server, Password) M:remove_user(User, Server, Password)
end, error, auth_modules(Server)), end, error, auth_modules(Server)),
case R of case R of
ok -> ejabberd_hooks:run(remove_user, list_to_binary(exmpp_stringprep:nameprep(Server)), ok -> ejabberd_hooks:run(remove_user, list_to_binary(exmpp_stringprep:nameprep(Server)),
[list_to_binary(User), list_to_binary(Server)]); [list_to_binary(User), list_to_binary(Server)]);
_ -> none _ -> none
end, end,