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_anonymous.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_anonymous.erl')
-rw-r--r-- | src/ejabberd_auth_anonymous.erl | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index 51eab74b7..a75af709e 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -26,9 +26,11 @@ -module(ejabberd_auth_anonymous). -behaviour(ejabberd_config). +-behaviour(ejabberd_auth). -author('mickael.remond@process-one.net'). -export([start/1, + stop/1, allow_anonymous/1, is_sasl_anonymous_enabled/1, is_login_anonymous_enabled/1, @@ -59,6 +61,12 @@ start(Host) -> ?MODULE, unregister_connection, 100), ok. +stop(Host) -> + ejabberd_hooks:delete(sm_register_connection_hook, Host, + ?MODULE, register_connection, 100), + ejabberd_hooks:delete(sm_remove_connection_hook, Host, + ?MODULE, unregister_connection, 100). + %% Return true if anonymous is allowed for host or false otherwise allow_anonymous(Host) -> lists:member(?MODULE, ejabberd_auth:auth_modules(Host)). @@ -93,21 +101,12 @@ is_login_anonymous_enabled(Host) -> %% Return the anonymous protocol to use: sasl_anon|login_anon|both %% defaults to login_anon anonymous_protocol(Host) -> - ejabberd_config:get_option( - {anonymous_protocol, Host}, - fun(sasl_anon) -> sasl_anon; - (login_anon) -> login_anon; - (both) -> both - end, - sasl_anon). + ejabberd_config:get_option({anonymous_protocol, Host}, sasl_anon). %% Return true if multiple connections have been allowed in the config file %% defaults to false allow_multiple_connections(Host) -> - ejabberd_config:get_option( - {allow_multiple_connections, Host}, - fun(V) when is_boolean(V) -> V end, - false). + ejabberd_config:get_option({allow_multiple_connections, Host}, false). anonymous_user_exist(User, Server) -> lists:any( |