25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +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,30 +207,41 @@ 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),
LServer = exmpp_stringprep:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read(passwd, US) of case catch mnesia:dirty_read(passwd, US) of
[#passwd{password = Password}] -> [#passwd{password = Password}] ->
Password; Password;
_ -> _ ->
false false
end
catch
_ ->
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),
LServer = exmpp_stringprep:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read(passwd, US) of case catch mnesia:dirty_read(passwd, US) of
[#passwd{password = Password}] -> [#passwd{password = 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),
LServer = exmpp_stringprep:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read({passwd, US}) of case catch mnesia:dirty_read({passwd, US}) of
[] -> [] ->
@ -239,21 +250,31 @@ is_user_exists(User, Server) ->
true; true;
_ -> _ ->
false false
end
catch
_ ->
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),
LServer = exmpp_stringprep:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
F = fun() -> F = fun() ->
mnesia:delete({passwd, US}) mnesia:delete({passwd, US})
end, end,
mnesia:transaction(F), mnesia:transaction(F),
ejabberd_hooks:run(remove_user, LServer, [User, Server]). 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),
LServer = exmpp_stringprep:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
F = fun() -> F = fun() ->
case mnesia:read({passwd, US}) of case mnesia:read({passwd, US}) of
@ -274,6 +295,10 @@ remove_user(User, Server, Password) ->
Res; Res;
_ -> _ ->
bad_request bad_request
end
catch
_ ->
bad_request
end. end.