diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-04-29 11:39:40 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-04-29 11:39:40 +0300 |
commit | b82b93f8f0c229e94a89469b0754bab0e28cd17c (patch) | |
tree | 56f5c7a25aa19254b4f30b1cf33fc34dcbadcbb7 /src/ejabberd_auth_external.erl | |
parent | Don't re-define validation functions in multiple places (diff) |
Don't validate an option in ejabberd_config:get_option() functions
The commit introduces the following changes:
* Now there is no need to pass validating function in
ejabberd_config:get_option() functions, because the configuration
keeps already validated values.
* New function ejabberd_config:get_option/1 is introduced
* Function ejabberd_config:get_option/3 is deprecated. If the function
is still called, the second argument (validating function) is simply
ignored.
* The second argument for ejabberd_config:get_option/2 is now
a default value, not a validating function.
Diffstat (limited to 'src/ejabberd_auth_external.erl')
-rw-r--r-- | src/ejabberd_auth_external.erl | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl index 4ba76cd99..8ba2e2b22 100644 --- a/src/ejabberd_auth_external.erl +++ b/src/ejabberd_auth_external.erl @@ -48,12 +48,7 @@ %%% API %%%---------------------------------------------------------------------- start(Host) -> - Cmd = ejabberd_config:get_option( - {extauth_program, Host}, - fun(V) -> - binary_to_list(iolist_to_binary(V)) - end, - "extauth"), + Cmd = ejabberd_config:get_option({extauth_program, Host}, "extauth"), extauth:start(Host, Cmd), check_cache_last_options(Host), ejabberd_auth_mnesia:start(Host). @@ -179,12 +174,8 @@ remove_user(User, Server, Password) -> %% @spec (Host::string()) -> false | {true, CacheTime::integer()} get_cache_option(Host) -> - case ejabberd_config:get_option( - {extauth_cache, Host}, - fun(false) -> undefined; - (I) when is_integer(I), I >= 0 -> I - end) of - undefined -> false; + case ejabberd_config:get_option({extauth_cache, Host}, false) of + false -> false; CacheTime -> {true, CacheTime} end. @@ -319,12 +310,11 @@ get_mod_last_configured(Server) -> end. is_configured(Host, Module) -> - Os = ejabberd_config:get_option({modules, Host}, - fun(M) when is_list(M) -> M end), + Os = ejabberd_config:get_option({modules, Host}, []), lists:keymember(Module, 1, Os). opt_type(extauth_cache) -> - fun (false) -> undefined; + fun (false) -> false; (I) when is_integer(I), I >= 0 -> I end; opt_type(extauth_program) -> |