25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Replace jlib:*prep/1 by exmpp_stringprep:*prep/1 and change the error

handling.

PR:		EJABP-1

SVN Revision: 1621
This commit is contained in:
Jean-Sébastien Pédron 2008-10-10 14:37:26 +00:00
parent 53bea055aa
commit 285b3858dd
2 changed files with 76 additions and 48 deletions

View File

@ -18,6 +18,9 @@
* src/ejabberd_c2s.erl (handle_sync_event/4): Remove a remaining * src/ejabberd_c2s.erl (handle_sync_event/4): Remove a remaining
jlib:jid_remove_resource/1 call. jlib:jid_remove_resource/1 call.
* src/ejabberd_auth_internal.erl: Replace jlib:*prep/1 by
exmpp_stringprep:*prep/1 and change the error handling.
2008-10-09 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-10-09 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/ejabberd_c2s.erl: Fix handling of unauthenticated stanzas which * src/ejabberd_c2s.erl: Fix handling of unauthenticated stanzas which

View File

@ -207,71 +207,96 @@ get_vh_registered_users_number(Server, _) ->
get_vh_registered_users_number(Server). get_vh_registered_users_number(Server).
get_password(User, Server) -> get_password(User, Server) ->
LUser = jlib:nodeprep(User), try
LServer = jlib:nameprep(Server), LUser = exmpp_stringprep:nodeprep(User),
US = {LUser, LServer}, LServer = exmpp_stringprep:nameprep(Server),
case catch mnesia:dirty_read(passwd, US) of US = {LUser, LServer},
[#passwd{password = Password}] -> case catch mnesia:dirty_read(passwd, US) of
Password; [#passwd{password = Password}] ->
Password;
_ ->
false
end
catch
_ -> _ ->
false false
end. end.
get_password_s(User, Server) -> get_password_s(User, Server) ->
LUser = jlib:nodeprep(User), try
LServer = jlib:nameprep(Server), LUser = exmpp_stringprep:nodeprep(User),
US = {LUser, LServer}, LServer = exmpp_stringprep:nameprep(Server),
case catch mnesia:dirty_read(passwd, US) of US = {LUser, LServer},
[#passwd{password = Password}] -> case catch mnesia:dirty_read(passwd, US) of
Password; [#passwd{password = Password}] ->
Password;
_ ->
[]
end
catch
_ -> _ ->
[] []
end. end.
is_user_exists(User, Server) -> is_user_exists(User, Server) ->
LUser = jlib:nodeprep(User), try
LServer = jlib:nameprep(Server), LUser = exmpp_stringprep:nodeprep(User),
US = {LUser, LServer}, LServer = exmpp_stringprep:nameprep(Server),
case catch mnesia:dirty_read({passwd, US}) of US = {LUser, LServer},
[] -> case catch mnesia:dirty_read({passwd, US}) of
false; [] ->
[_] -> false;
true; [_] ->
true;
_ ->
false
end
catch
_ -> _ ->
false false
end. end.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), try
LServer = jlib:nameprep(Server), LUser = exmpp_stringprep:nodeprep(User),
US = {LUser, LServer}, LServer = exmpp_stringprep:nameprep(Server),
F = fun() -> US = {LUser, LServer},
mnesia:delete({passwd, US}) F = fun() ->
end, mnesia:delete({passwd, US})
mnesia:transaction(F), end,
ejabberd_hooks:run(remove_user, LServer, [User, Server]). mnesia:transaction(F),
ejabberd_hooks:run(remove_user, LServer, [User, Server])
catch
_ ->
ok
end.
remove_user(User, Server, Password) -> remove_user(User, Server, Password) ->
LUser = jlib:nodeprep(User), try
LServer = jlib:nameprep(Server), LUser = exmpp_stringprep:nodeprep(User),
US = {LUser, LServer}, LServer = exmpp_stringprep:nameprep(Server),
F = fun() -> US = {LUser, LServer},
case mnesia:read({passwd, US}) of F = fun() ->
[#passwd{password = Password}] -> case mnesia:read({passwd, US}) of
mnesia:delete({passwd, US}), [#passwd{password = Password}] ->
ok; mnesia:delete({passwd, US}),
[_] -> ok;
not_allowed; [_] ->
_ -> not_allowed;
not_exists _ ->
end not_exists
end, end
case mnesia:transaction(F) of end,
{atomic, ok} -> case mnesia:transaction(F) of
ejabberd_hooks:run(remove_user, LServer, [User, Server]), {atomic, ok} ->
ok; ejabberd_hooks:run(remove_user, LServer, [User, Server]),
{atomic, Res} -> ok;
Res; {atomic, Res} ->
Res;
_ ->
bad_request
end
catch
_ -> _ ->
bad_request bad_request
end. end.