From 1a6c1623711facd72935be13479029f8c7fabf7c Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 10 Jun 2010 00:52:38 +0200 Subject: [PATCH] Fix Dialyzer errors in auth modules --- src/ejabberd_auth.erl | 7 ++----- src/ejabberd_auth_anonymous.erl | 6 +++--- src/ejabberd_auth_internal.erl | 26 ++++++++++++++------------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl index 29cee06c6..00fb0338d 100644 --- a/src/ejabberd_auth.erl +++ b/src/ejabberd_auth.erl @@ -393,11 +393,8 @@ remove_user(User, Server) when is_list(User), is_list(Server) -> fun(M) -> M:remove_user(User, Server) end, auth_modules(Server)), - case R of - ok -> ejabberd_hooks:run(remove_user, list_to_binary(exmpp_stringprep:nameprep(Server)), - [list_to_binary(User), list_to_binary(Server)]); - _ -> none - end, + ejabberd_hooks:run(remove_user, list_to_binary(exmpp_stringprep:nameprep(Server)), + [list_to_binary(User), list_to_binary(Server)]), R. %% @spec (User, Server, Password) -> ok | not_exists | not_allowed | bad_request | error diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index 53b251f06..296613593 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -201,8 +201,8 @@ register_connection(SID, JID, Info) when ?IS_JID(JID) -> %% @doc Remove an anonymous user from the anonymous users table. unregister_connection(SID, JID, _) when ?IS_JID(JID) -> - LUser = exmpp_jid:prep_node(JID), - LServer = exmpp_jid:prep_domain(JID), + LUser = exmpp_jid:prep_node_as_list(JID), + LServer = exmpp_jid:prep_domain_as_list(JID), purge_hook(anonymous_user_exist(LUser, LServer), LUser, LServer), remove_connection(SID, LUser, LServer). @@ -215,7 +215,7 @@ unregister_connection(SID, JID, _) when ?IS_JID(JID) -> purge_hook(false, _LUser, _LServer) -> ok; purge_hook(true, LUser, LServer) when is_list(LUser), is_list(LServer) -> - ejabberd_hooks:run(anonymous_purge_hook, LServer, [LUser, LServer]). + ejabberd_hooks:run(anonymous_purge_hook, list_to_binary(LServer), [LUser, LServer]). %% --------------------------------- %% Specific anonymous auth functions diff --git a/src/ejabberd_auth_internal.erl b/src/ejabberd_auth_internal.erl index b55a9bd06..8aa07b238 100644 --- a/src/ejabberd_auth_internal.erl +++ b/src/ejabberd_auth_internal.erl @@ -133,13 +133,14 @@ check_password(User, Server, Password, Digest, DigestGen) -> %% Password = string() set_password(User, Server, Password) -> - LUser = exmpp_stringprep:nodeprep(User), - LServer = exmpp_stringprep:nameprep(Server), - US = {LUser, LServer}, - if - (LUser == error) or (LServer == error) -> + LUser = (catch exmpp_stringprep:nodeprep(User)), + LServer = (catch exmpp_stringprep:nameprep(Server)), + case {LUser, LServer} of + {{stringprep, _, invalid_string, _}, _} -> {error, invalid_jid}; - true -> + {_, {stringprep, _, invalid_string, _}} -> + {error, invalid_jid}; + US -> F = fun() -> mnesia:write(#passwd{us = US, password = Password}) @@ -154,13 +155,14 @@ set_password(User, Server, Password) -> %% Password = string() try_register(User, Server, Password) -> - LUser = exmpp_stringprep:nodeprep(User), - LServer = exmpp_stringprep:nameprep(Server), - US = {LUser, LServer}, - if - (LUser == error) or (LServer == error) -> + LUser = (catch exmpp_stringprep:nodeprep(User)), + LServer = (catch exmpp_stringprep:nameprep(Server)), + case {LUser, LServer} of + {{stringprep, _, invalid_string, _}, _} -> {error, invalid_jid}; - true -> + {_, {stringprep, _, invalid_string, _}} -> + {error, invalid_jid}; + US -> F = fun() -> case mnesia:read({passwd, US}) of [] ->