From cdb191bb48ec8aa251031f7de0f963dee00f3022 Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Thu, 11 May 2017 15:49:06 +0300 Subject: [PATCH] Rename is_user_exists -> user_exists --- src/ejabberd_auth.erl | 34 ++++++++++++++++----------------- src/ejabberd_auth_anonymous.erl | 6 +++--- src/ejabberd_auth_external.erl | 6 +++--- src/ejabberd_auth_ldap.erl | 8 ++++---- src/ejabberd_auth_pam.erl | 4 ++-- src/ejabberd_sm.erl | 4 ++-- src/ejabberd_web_admin.erl | 4 ++-- src/extauth.erl | 4 ++-- src/mod_admin_extra.erl | 4 ++-- src/mod_configure.erl | 4 ++-- src/mod_disco.erl | 2 +- src/mod_register.erl | 2 +- src/mod_register_web.erl | 2 +- src/mod_shared_roster_ldap.erl | 2 +- src/mod_vcard_ldap.erl | 2 +- 15 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl index 23ed0eeae..230bd87b5 100644 --- a/src/ejabberd_auth.erl +++ b/src/ejabberd_auth.erl @@ -39,7 +39,7 @@ count_users/1, import/5, import_start/2, count_users/2, get_password/2, get_password_s/2, get_password_with_authmodule/2, - is_user_exists/2, is_user_exists_in_other_modules/3, + user_exists/2, user_exists_in_other_modules/3, remove_user/2, remove_user/3, plain_password_required/1, store_type/1, entropy/1, backend_type/1, password_format/1]). %% gen_server callbacks @@ -73,7 +73,7 @@ -callback store_type(binary()) -> plain | external | scram. -callback set_password(binary(), binary(), binary()) -> ok | {error, atom()}. -callback remove_user(binary(), binary()) -> ok | {error, any()}. --callback is_user_exists(binary(), binary()) -> boolean() | {error, atom()}. +-callback user_exists(binary(), binary()) -> boolean() | {error, atom()}. -callback check_password(binary(), binary(), binary(), binary()) -> boolean(). -callback try_register(binary(), binary(), password()) -> ok | {error, atom()}. -callback get_users(binary(), opts()) -> [{binary(), binary()}]. @@ -84,7 +84,7 @@ -optional_callbacks([set_password/3, remove_user/2, - is_user_exists/2, + user_exists/2, check_password/4, try_register/3, get_users/2, @@ -250,7 +250,7 @@ set_password(User, Server, Password) -> try_register(User, Server, Password) -> case validate_credentials(User, Server, Password) of {ok, LUser, LServer} -> - case is_user_exists(LUser, LServer) of + case user_exists(LUser, LServer) of true -> {error, exists}; false -> @@ -357,15 +357,15 @@ get_password_with_authmodule(User, Server) -> {false, undefined} end. --spec is_user_exists(binary(), binary()) -> boolean(). -is_user_exists(_User, <<"">>) -> +-spec user_exists(binary(), binary()) -> boolean(). +user_exists(_User, <<"">>) -> false; -is_user_exists(User, Server) -> +user_exists(User, Server) -> case validate_credentials(User, Server) of {ok, LUser, LServer} -> lists:any( fun(M) -> - case db_is_user_exists(LUser, LServer, M) of + case db_user_exists(LUser, LServer, M) of {error, _} -> false; Else -> @@ -376,19 +376,19 @@ is_user_exists(User, Server) -> false end. --spec is_user_exists_in_other_modules(atom(), binary(), binary()) -> boolean() | maybe. -is_user_exists_in_other_modules(Module, User, Server) -> - is_user_exists_in_other_modules_loop( +-spec user_exists_in_other_modules(atom(), binary(), binary()) -> boolean() | maybe. +user_exists_in_other_modules(Module, User, Server) -> + user_exists_in_other_modules_loop( auth_modules(Server) -- [Module], User, Server). -is_user_exists_in_other_modules_loop([], _User, _Server) -> +user_exists_in_other_modules_loop([], _User, _Server) -> false; -is_user_exists_in_other_modules_loop([AuthModule | AuthModules], User, Server) -> - case db_is_user_exists(User, Server, AuthModule) of +user_exists_in_other_modules_loop([AuthModule | AuthModules], User, Server) -> + case db_user_exists(User, Server, AuthModule) of true -> true; false -> - is_user_exists_in_other_modules_loop(AuthModules, User, Server); + user_exists_in_other_modules_loop(AuthModules, User, Server); {error, _} -> maybe end. @@ -537,14 +537,14 @@ db_get_password(User, Server, Mod) -> Mod:get_password(User, Server) end. -db_is_user_exists(User, Server, Mod) -> +db_user_exists(User, Server, Mod) -> case db_get_password(User, Server, Mod) of {ok, _} -> true; error -> case Mod:store_type(Server) of external -> - Mod:is_user_exists(User, Server); + Mod:user_exists(User, Server); _ -> false end diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index b3ae1f6dd..a4f3ac1c5 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -40,7 +40,7 @@ unregister_connection/3 ]). --export([login/2, check_password/4, is_user_exists/2, +-export([login/2, check_password/4, user_exists/2, get_users/2, count_users/2, store_type/1, plain_password_required/1, opt_type/1]). @@ -135,7 +135,7 @@ unregister_connection(_SID, %% --------------------------------- check_password(User, _AuthzId, Server, _Password) -> case - ejabberd_auth:is_user_exists_in_other_modules(?MODULE, + ejabberd_auth:user_exists_in_other_modules(?MODULE, User, Server) of %% If user exists in other module, reject anonnymous authentication @@ -165,7 +165,7 @@ get_users(Server, _) -> count_users(Server, Opts) -> length(get_users(Server, Opts)). -is_user_exists(User, Server) -> +user_exists(User, Server) -> anonymous_user_exist(User, Server). plain_password_required(_) -> diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl index 5b2b26c1a..c56697610 100644 --- a/src/ejabberd_auth_external.erl +++ b/src/ejabberd_auth_external.erl @@ -32,7 +32,7 @@ -behaviour(ejabberd_auth). -export([start/1, stop/1, set_password/3, check_password/4, - try_register/3, is_user_exists/2, remove_user/2, + try_register/3, user_exists/2, remove_user/2, store_type/1, plain_password_required/1, opt_type/1]). -include("ejabberd.hrl"). @@ -68,8 +68,8 @@ set_password(User, Server, Password) -> try_register(User, Server, Password) -> extauth:try_register(User, Server, Password). -is_user_exists(User, Server) -> - try extauth:is_user_exists(User, Server) of +user_exists(User, Server) -> + try extauth:user_exists(User, Server) of Res -> Res catch _:Error -> diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl index 15abebedc..21f7ca62c 100644 --- a/src/ejabberd_auth_ldap.erl +++ b/src/ejabberd_auth_ldap.erl @@ -37,7 +37,7 @@ handle_cast/2, terminate/2, code_change/3]). -export([start/1, stop/1, start_link/1, set_password/3, - check_password/4, is_user_exists/2, + check_password/4, user_exists/2, get_users/2, count_users/2, store_type/1, plain_password_required/1, opt_type/1]). @@ -147,8 +147,8 @@ count_users(Server, Opts) -> length(get_users(Server, Opts)). %% @spec (User, Server) -> true | false | {error, Error} -is_user_exists(User, Server) -> - case catch is_user_exists_ldap(User, Server) of +user_exists(User, Server) -> + case catch user_exists_ldap(User, Server) of {'EXIT', _Error} -> {error, db_failure}; Result -> Result end. @@ -218,7 +218,7 @@ get_users_ldap(Server) -> _ -> [] end. -is_user_exists_ldap(User, Server) -> +user_exists_ldap(User, Server) -> {ok, State} = eldap_utils:get_state(Server, ?MODULE), case find_user_dn(User, State) of false -> false; diff --git a/src/ejabberd_auth_pam.erl b/src/ejabberd_auth_pam.erl index f865f36f6..f31ba4c9a 100644 --- a/src/ejabberd_auth_pam.erl +++ b/src/ejabberd_auth_pam.erl @@ -31,7 +31,7 @@ -behaviour(ejabberd_auth). -export([start/1, stop/1, check_password/4, - is_user_exists/2, store_type/1, plain_password_required/1, + user_exists/2, store_type/1, plain_password_required/1, opt_type/1]). start(_Host) -> @@ -57,7 +57,7 @@ check_password(User, AuthzId, Host, Password) -> end end. -is_user_exists(User, Host) -> +user_exists(User, Host) -> Service = get_pam_service(Host), UserInfo = case get_pam_userinfotype(Host) of username -> User; diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 92c6bb94f..9ab38a763 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -178,7 +178,7 @@ close_session(SID, User, Server, Resource) -> subscribe | subscribed | unsubscribe | unsubscribed, binary()) -> boolean() | {stop, false}. check_in_subscription(Acc, User, Server, _JID, _Type, _Reason) -> - case ejabberd_auth:is_user_exists(User, Server) of + case ejabberd_auth:user_exists(User, Server) of true -> Acc; false -> {stop, false} end. @@ -716,7 +716,7 @@ route_message(#message{to = To, type = Type} = Packet) -> end, PrioRes); _ -> - case ejabberd_auth:is_user_exists(LUser, LServer) andalso + case ejabberd_auth:user_exists(LUser, LServer) andalso is_privacy_allow(Packet) of true -> ejabberd_hooks:run_fold(offline_message_hook, diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index 6fdac1971..4c2ca730a 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -281,7 +281,7 @@ get_auth_account(HostOfRule, AccessRule, User, Server, true -> {ok, {User, Server}} end; false -> - case ejabberd_auth:is_user_exists(User, Server) of + case ejabberd_auth:user_exists(User, Server) of true -> {unauthorized, <<"bad-password">>}; false -> {unauthorized, <<"inexistent-account">>} end @@ -1025,7 +1025,7 @@ process_admin(Host, process_admin(Host, #request{path = [<<"user">>, U], auth = {_, _Auth, AJID}, q = Query, lang = Lang}) -> - case ejabberd_auth:is_user_exists(U, Host) of + case ejabberd_auth:user_exists(U, Host) of true -> Res = user_info(U, Host, Query, Lang), make_xhtml(Res, Host, Lang, AJID); diff --git a/src/extauth.erl b/src/extauth.erl index 70f32bf8f..9f04a44ea 100644 --- a/src/extauth.erl +++ b/src/extauth.erl @@ -31,7 +31,7 @@ -export([start/2, stop/1, init/2, check_password/3, set_password/3, try_register/3, remove_user/2, - remove_user/3, is_user_exists/2, opt_type/1]). + remove_user/3, user_exists/2, opt_type/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -73,7 +73,7 @@ get_process_name(Host, Integer) -> check_password(User, Server, Password) -> call_port(Server, [<<"auth">>, User, Server, Password]). -is_user_exists(User, Server) -> +user_exists(User, Server) -> call_port(Server, [<<"isuser">>, User, Server]). set_password(User, Server, Password) -> diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index 982772af0..0b3b007ce 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -210,7 +210,7 @@ get_commands_spec() -> result_desc = "Result tuple"}, #ejabberd_commands{name = check_account, tags = [accounts], desc = "Check if an account exists or not", - module = ejabberd_auth, function = is_user_exists, + module = ejabberd_auth, function = user_exists, args = [{user, binary}, {host, binary}], args_example = [<<"peter">>, <<"myserver.com">>], args_desc = ["User name to check", "Server to check"], @@ -1638,7 +1638,7 @@ decide_rip_jid({UName, UServer}, Match_list) -> Match_list). user_action(User, Server, Fun, OK) -> - case ejabberd_auth:is_user_exists(User, Server) of + case ejabberd_auth:user_exists(User, Server) of true -> case catch Fun() of OK -> ok; diff --git a/src/mod_configure.erl b/src/mod_configure.erl index f3eb496d8..3bb9f2279 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -1541,7 +1541,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>), Server = JID#jid.lserver, true = Server == Host orelse get_permission_level(From) == global, - true = ejabberd_auth:is_user_exists(User, Server), + true = ejabberd_auth:user_exists(User, Server), {User, Server} end, AccountStringList), @@ -1610,7 +1610,7 @@ set_form(From, Host, Server = JID#jid.lserver, true = Server == Host orelse get_permission_level(From) == global, - true = ejabberd_auth:is_user_exists(User, Server), + true = ejabberd_auth:user_exists(User, Server), ejabberd_auth:set_password(User, Server, Password), {result, undefined}; set_form(From, Host, diff --git a/src/mod_disco.erl b/src/mod_disco.erl index 7fde1b410..76be408f4 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -376,7 +376,7 @@ process_sm_iq_info(#iq{type = get, lang = Lang, get_sm_identity(Acc, _From, #jid{luser = LUser, lserver = LServer}, _Node, _Lang) -> Acc ++ - case ejabberd_auth:is_user_exists(LUser, LServer) of + case ejabberd_auth:user_exists(LUser, LServer) of true -> [#identity{category = <<"account">>, type = <<"registered">>}]; _ -> [] diff --git a/src/mod_register.erl b/src/mod_register.erl index 5167370c1..c2efca5c1 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -198,7 +198,7 @@ process_iq(#iq{type = get, from = From, to = To, id = ID, lang = Lang} = IQ, {IsRegistered, Username} = case From of #jid{user = User, lserver = Server} -> - case ejabberd_auth:is_user_exists(User, Server) of + case ejabberd_auth:user_exists(User, Server) of true -> {true, User}; false -> diff --git a/src/mod_register_web.erl b/src/mod_register_web.erl index d5e4112c3..16c2d8020 100644 --- a/src/mod_register_web.erl +++ b/src/mod_register_web.erl @@ -438,7 +438,7 @@ change_password(Username, Host, PasswordOld, end. check_account_exists(Username, Host) -> - case ejabberd_auth:is_user_exists(Username, Host) of + case ejabberd_auth:user_exists(Username, Host) of true -> account_exists; false -> account_doesnt_exist end. diff --git a/src/mod_shared_roster_ldap.erl b/src/mod_shared_roster_ldap.erl index 08220f7ec..bc7694fe4 100644 --- a/src/mod_shared_roster_ldap.erl +++ b/src/mod_shared_roster_ldap.erl @@ -390,7 +390,7 @@ search_group_info(State, Group) -> end end, AuthChecker = case State#state.auth_check of - true -> fun ejabberd_auth:is_user_exists/2; + true -> fun ejabberd_auth:user_exists/2; _ -> fun (_U, _S) -> true end end, case eldap_search(State, diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index f97eb18a9..967a2c4cf 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -148,7 +148,7 @@ search_items(Entries, State) -> {U, UIDAttrFormat} -> case eldap_utils:get_user_part(U, UIDAttrFormat) of {ok, Username} -> - case ejabberd_auth:is_user_exists(Username, + case ejabberd_auth:user_exists(Username, LServer) of true -> RFields = lists:map(