mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
* src/mod_register.erl: Change password using mod_register always
returns success regardless of real result (EJAB-723) * src/ejabberd_auth.erl: Likewise * src/ejabberd_auth_external.erl: Likewise * src/ejabberd_auth_internal.erl: Likewise * src/ejabberd_auth_odbc.erl: Likewise SVN Revision: 1530
This commit is contained in:
parent
7b1547b2bd
commit
4ae1bda33f
11
ChangeLog
11
ChangeLog
@ -1,3 +1,12 @@
|
||||
2008-08-18 Badlop <badlop@process-one.net>
|
||||
|
||||
* src/mod_register.erl: Change password using mod_register always
|
||||
returns success regardless of real result (EJAB-723)
|
||||
* src/ejabberd_auth.erl: Likewise
|
||||
* src/ejabberd_auth_external.erl: Likewise
|
||||
* src/ejabberd_auth_internal.erl: Likewise
|
||||
* src/ejabberd_auth_odbc.erl: Likewise
|
||||
|
||||
2008-08-18 Christophe Romain <christophe.romain@process-one.net>
|
||||
|
||||
* src/mod_pubsub/node_dispatch.erl: Fix call to unexported function
|
||||
@ -6,7 +15,7 @@
|
||||
2008-08-17 Badlop <badlop@process-one.net>
|
||||
|
||||
* contrib/extract_translations/extract_translations.erl: Use
|
||||
Gettext PO for translators, export to ejabberd MSG (EJAB-468)
|
||||
Gettext PO for translators, export to ejabberd MSG (EJAB-648)
|
||||
* contrib/extract_translations/prepare-translation.sh: Likewise
|
||||
* doc/guide.tex: Likewise
|
||||
* doc/guide.html: Likewise
|
||||
|
@ -127,9 +127,12 @@ check_password_with_authmodule(User, Server, Password, StreamID, Digest) ->
|
||||
[AuthMod | _] -> {true, AuthMod}
|
||||
end.
|
||||
|
||||
%% We do not allow empty password:
|
||||
%% @spec (User::string(), Server::string(), Password::string()) ->
|
||||
%% ok | {error, ErrorType}
|
||||
%% where ErrorType = empty_password | not_allowed | invalid_jid
|
||||
set_password(_User, _Server, "") ->
|
||||
{error, not_allowed};
|
||||
%% We do not allow empty password
|
||||
{error, empty_password};
|
||||
set_password(User, Server, Password) ->
|
||||
lists:foldl(
|
||||
fun(M, {error, _}) ->
|
||||
@ -138,8 +141,8 @@ set_password(User, Server, Password) ->
|
||||
Res
|
||||
end, {error, not_allowed}, auth_modules(Server)).
|
||||
|
||||
%% We do not allow empty password:
|
||||
try_register(_User, _Server, "") ->
|
||||
%% We do not allow empty password
|
||||
{error, not_allowed};
|
||||
try_register(User, Server, Password) ->
|
||||
case is_user_exists(User,Server) of
|
||||
|
@ -61,7 +61,10 @@ check_password(User, Server, Password, _StreamID, _Digest) ->
|
||||
check_password(User, Server, Password).
|
||||
|
||||
set_password(User, Server, Password) ->
|
||||
extauth:set_password(User, Server, Password).
|
||||
case extauth:set_password(User, Server, Password) of
|
||||
true -> ok;
|
||||
_ -> {error, unknown_problem}
|
||||
end.
|
||||
|
||||
try_register(_User, _Server, _Password) ->
|
||||
{error, not_allowed}.
|
||||
|
@ -98,6 +98,8 @@ check_password(User, Server, Password, StreamID, Digest) ->
|
||||
false
|
||||
end.
|
||||
|
||||
%% @spec (User::string(), Server::string(), Password::string()) ->
|
||||
%% ok | {error, invalid_jid}
|
||||
set_password(User, Server, Password) ->
|
||||
LUser = jlib:nodeprep(User),
|
||||
LServer = jlib:nameprep(Server),
|
||||
@ -110,7 +112,8 @@ set_password(User, Server, Password) ->
|
||||
mnesia:write(#passwd{us = US,
|
||||
password = Password})
|
||||
end,
|
||||
mnesia:transaction(F)
|
||||
{atomic, ok} = mnesia:transaction(F),
|
||||
ok
|
||||
end.
|
||||
|
||||
try_register(User, Server, Password) ->
|
||||
|
@ -101,6 +101,8 @@ check_password(User, Server, Password, StreamID, Digest) ->
|
||||
end
|
||||
end.
|
||||
|
||||
%% @spec (User::string(), Server::string(), Password::string()) ->
|
||||
%% ok | {error, invalid_jid}
|
||||
set_password(User, Server, Password) ->
|
||||
case jlib:nodeprep(User) of
|
||||
error ->
|
||||
@ -109,7 +111,10 @@ set_password(User, Server, Password) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
Pass = ejabberd_odbc:escape(Password),
|
||||
LServer = jlib:nameprep(Server),
|
||||
catch odbc_queries:set_password_t(LServer, Username, Pass)
|
||||
case catch odbc_queries:set_password_t(LServer, Username, Pass) of
|
||||
{atomic, ok} -> ok;
|
||||
Other -> {error, Other}
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
|
@ -163,8 +163,7 @@ process_iq(From, To,
|
||||
Password = xml:get_tag_cdata(PTag),
|
||||
case From of
|
||||
#jid{user = User, lserver = Server} ->
|
||||
ejabberd_auth:set_password(User, Server, Password),
|
||||
IQ#iq{type = result, sub_el = [SubEl]};
|
||||
try_set_password(User, Server, Password, IQ, SubEl);
|
||||
_ ->
|
||||
case try_register(User, Server, Password,
|
||||
Source, Lang) of
|
||||
@ -194,6 +193,20 @@ process_iq(From, To,
|
||||
{xmlelement, "password", [], []}]}]}
|
||||
end.
|
||||
|
||||
%% @doc Try to change password and return IQ response
|
||||
try_set_password(User, Server, Password, IQ, SubEl) ->
|
||||
case ejabberd_auth:set_password(User, Server, Password) of
|
||||
ok ->
|
||||
IQ#iq{type = result, sub_el = [SubEl]};
|
||||
{error, empty_password} ->
|
||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_BAD_REQUEST]};
|
||||
{error, not_allowed} ->
|
||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
|
||||
{error, invalid_jid} ->
|
||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_ITEM_NOT_FOUND]};
|
||||
_ ->
|
||||
IQ#iq{type = error, sub_el = [SubEl, ?ERR_INTERNAL_SERVER_ERROR]}
|
||||
end.
|
||||
|
||||
try_register(User, Server, Password, Source, Lang) ->
|
||||
case jlib:is_nodename(User) of
|
||||
|
Loading…
Reference in New Issue
Block a user