mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Don't use same value in cache for user don't exist and wrong password
By doing this check_password that returned info about mismatched password caused user_exists checks performed after that to return wrongly that account doesn't exist.
This commit is contained in:
parent
7655e10ba4
commit
b4ea1625e4
@ -605,6 +605,7 @@ db_get_password(User, Server, Mod) ->
|
|||||||
false when UseCache ->
|
false when UseCache ->
|
||||||
case ets_cache:lookup(cache_tab(Mod), {User, Server}) of
|
case ets_cache:lookup(cache_tab(Mod), {User, Server}) of
|
||||||
{ok, exists} -> error;
|
{ok, exists} -> error;
|
||||||
|
not_found -> error;
|
||||||
Other -> Other
|
Other -> Other
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
@ -621,20 +622,29 @@ db_user_exists(User, Server, Mod) ->
|
|||||||
case db_get_password(User, Server, Mod) of
|
case db_get_password(User, Server, Mod) of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
true;
|
true;
|
||||||
|
not_found ->
|
||||||
|
false;
|
||||||
error ->
|
error ->
|
||||||
case {Mod:store_type(Server), use_cache(Mod, Server)} of
|
case {Mod:store_type(Server), use_cache(Mod, Server)} of
|
||||||
{external, true} ->
|
{external, true} ->
|
||||||
case ets_cache:lookup(
|
Val = case ets_cache:lookup(cache_tab(Mod), {User, Server}, error) of
|
||||||
cache_tab(Mod), {User, Server},
|
error ->
|
||||||
fun() ->
|
ets_cache:update(cache_tab(Mod), {User, Server}, {ok, exists},
|
||||||
case Mod:user_exists(User, Server) of
|
fun() ->
|
||||||
{CacheTag, true} -> {CacheTag, {ok, exists}};
|
case Mod:user_exists(User, Server) of
|
||||||
{CacheTag, false} -> {CacheTag, error};
|
{CacheTag, true} -> {CacheTag, {ok, exists}};
|
||||||
{_, {error, _}} = Err -> Err
|
{CacheTag, false} -> {CacheTag, not_found};
|
||||||
end
|
{_, {error, _}} = Err -> Err
|
||||||
end) of
|
end
|
||||||
|
end);
|
||||||
|
Other ->
|
||||||
|
Other
|
||||||
|
end,
|
||||||
|
case Val of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
true;
|
true;
|
||||||
|
not_found ->
|
||||||
|
false;
|
||||||
error ->
|
error ->
|
||||||
false;
|
false;
|
||||||
{error, _} = Err ->
|
{error, _} = Err ->
|
||||||
|
Loading…
Reference in New Issue
Block a user