UseCache = use_cache(Mod, Server),
case erlang:function_exported(Mod, get_password, 2) of
false when UseCache ->
- ets_cache:lookup(?AUTH_CACHE, {User, Server});
+ case ets_cache:lookup(?AUTH_CACHE, {User, Server}) of
+ {ok, exists} -> error;
+ Other -> Other
+ end;
false ->
error;
true when UseCache ->
error ->
case Mod:store_type(Server) of
external ->
- Mod:user_exists(User, Server);
+ case ets_cache:update(
+ ?AUTH_CACHE, {User, Server}, {ok, exists},
+ fun() ->
+ case Mod:user_exists(User, Server) of
+ true -> {ok, exists};
+ false -> error;
+ {error, _} = Err -> Err
+ end
+ end, cache_nodes(Mod, Server)) of
+ {ok, _} ->
+ true;
+ error ->
+ false
+ end;
_ ->
false
end