25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Rename is_user_exists -> user_exists

This commit is contained in:
Evgeniy Khramtsov 2017-05-11 15:49:06 +03:00
parent 633b68db11
commit cdb191bb48
15 changed files with 44 additions and 44 deletions

View File

@ -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

View File

@ -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(_) ->

View File

@ -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 ->

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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);

View File

@ -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) ->

View File

@ -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;

View File

@ -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,

View File

@ -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">>}];
_ -> []

View File

@ -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 ->

View File

@ -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.

View File

@ -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,

View File

@ -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(