mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-10 16:58:46 +01:00
80181dc618
commands, removed registered-users command * src/ejabberd_auth.erl: Added processing of registered-users command * src/ejabberd_auth_internal.erl: Likewise * src/ejabberd_auth_ldap.erl: Likewise * src/ejabberd_auth_odbc.erl: Likewise * src/ejabberd_app.erl: Added inititalization of ejabberd_ctl * src/ejabberd_sm.erl: Minor update SVN Revision: 510
102 lines
3.0 KiB
Erlang
102 lines
3.0 KiB
Erlang
%%%----------------------------------------------------------------------
|
|
%%% File : ejabberd_auth.erl
|
|
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
|
%%% Purpose : Authentification
|
|
%%% Created : 23 Nov 2002 by Alexey Shchepin <alexey@sevcom.net>
|
|
%%% Id : $Id$
|
|
%%%----------------------------------------------------------------------
|
|
|
|
-module(ejabberd_auth).
|
|
-author('alexey@sevcom.net').
|
|
-vsn('$Revision$ ').
|
|
|
|
%% External exports
|
|
-export([start/0,
|
|
set_password/3,
|
|
check_password/3,
|
|
check_password/5,
|
|
try_register/3,
|
|
dirty_get_registered_users/0,
|
|
get_vh_registered_users/1,
|
|
get_password/2,
|
|
get_password_s/2,
|
|
is_user_exists/2,
|
|
remove_user/2,
|
|
remove_user/3,
|
|
plain_password_required/1,
|
|
ctl_process_get_registered/3
|
|
]).
|
|
|
|
-include("ejabberd.hrl").
|
|
-include("ejabberd_ctl.hrl").
|
|
|
|
%%%----------------------------------------------------------------------
|
|
%%% API
|
|
%%%----------------------------------------------------------------------
|
|
start() ->
|
|
lists:foreach(fun(Host) ->
|
|
(auth_module(Host)):start(Host)
|
|
end, ?MYHOSTS).
|
|
|
|
plain_password_required(Server) ->
|
|
(auth_module(Server)):plain_password_required().
|
|
|
|
check_password(User, Server, Password) ->
|
|
(auth_module(Server)):check_password(User, Server, Password).
|
|
|
|
check_password(User, Server, Password, StreamID, Digest) ->
|
|
(auth_module(Server)):check_password(User, Server, Password, StreamID, Digest).
|
|
|
|
set_password(User, Server, Password) ->
|
|
(auth_module(Server)):set_password(User, Server, Password).
|
|
|
|
try_register(User, Server, Password) ->
|
|
case lists:member(jlib:nameprep(Server), ?MYHOSTS) of
|
|
true ->
|
|
(auth_module(Server)):try_register(User, Server, Password);
|
|
false ->
|
|
{error, not_allowed}
|
|
end.
|
|
|
|
dirty_get_registered_users() ->
|
|
(auth_module(?MYNAME)):dirty_get_registered_users().
|
|
|
|
get_vh_registered_users(Server) ->
|
|
(auth_module(Server)):get_vh_registered_users(Server).
|
|
|
|
get_password(User, Server) ->
|
|
(auth_module(Server)):get_password(User, Server).
|
|
|
|
get_password_s(User, Server) ->
|
|
(auth_module(Server)):get_password_s(User, Server).
|
|
|
|
is_user_exists(User, Server) ->
|
|
(auth_module(Server)):is_user_exists(User, Server).
|
|
|
|
remove_user(User, Server) ->
|
|
(auth_module(Server)):remove_user(User, Server).
|
|
|
|
remove_user(User, Server, Password) ->
|
|
(auth_module(Server)):remove_user(User, Server, Password).
|
|
|
|
|
|
ctl_process_get_registered(_Val, Host, ["registered-users"]) ->
|
|
Users = ejabberd_auth:get_vh_registered_users(Host),
|
|
NewLine = io_lib:format("~n", []),
|
|
SUsers = lists:sort(Users),
|
|
FUsers = lists:map(fun({U, _S}) -> [U, NewLine] end, SUsers),
|
|
io:format("~s", [FUsers]),
|
|
{stop, ?STATUS_SUCCESS};
|
|
ctl_process_get_registered(Val, _Host, _Args) ->
|
|
Val.
|
|
|
|
%%%----------------------------------------------------------------------
|
|
%%% Internal functions
|
|
%%%----------------------------------------------------------------------
|
|
|
|
auth_module(Server) ->
|
|
LServer = jlib:nameprep(Server),
|
|
Method = ejabberd_config:get_local_option({auth_method, LServer}),
|
|
list_to_atom("ejabberd_auth_" ++ atom_to_list(Method)).
|
|
|