diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2013-06-01 22:16:29 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2013-06-01 22:16:29 +0100 |
commit | a9f9b48512db25c77f006a35251ad484ade3d619 (patch) | |
tree | ec61b7045fdfa94d7077cc92c437699e14534004 | |
parent | 731c64bdc5cc00f4459353b727ce1827e32fe5e3 (diff) | |
download | rabbitmq-server-a9f9b48512db25c77f006a35251ad484ade3d619.tar.gz |
refactor: replace <module>:F with funs
the former is evil
-rw-r--r-- | src/rabbit_direct.erl | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl index 53144f3f..c18b5023 100644 --- a/src/rabbit_direct.erl +++ b/src/rabbit_direct.erl @@ -76,21 +76,23 @@ connect(User = #user{}, VHost, Protocol, Pid, Infos) -> end; connect({Username, Password}, VHost, Protocol, Pid, Infos) -> - connect0(check_user_pass_login, Username, Password, VHost, Protocol, Pid, - Infos); + connect0(fun () -> rabbit_access_control:check_user_pass_login( + Username, Password) end, + VHost, Protocol, Pid, Infos); connect(Username, VHost, Protocol, Pid, Infos) -> - connect0(check_user_login, Username, [], VHost, Protocol, Pid, Infos). + connect0(fun () -> rabbit_access_control:check_user_login( + Username, []) end, + VHost, Protocol, Pid, Infos). -connect0(FunctionName, U, P, VHost, Protocol, Pid, Infos) -> +connect0(AuthFun, VHost, Protocol, Pid, Infos) -> case rabbit:is_running() of - true -> - case rabbit_access_control:FunctionName(U, P) of - {ok, User} -> connect(User, VHost, Protocol, Pid, Infos); - {refused, _M, _A} -> {error, auth_failure} - end; - false -> - {error, broker_not_found_on_node} + true -> case AuthFun() of + {ok, User} -> connect(User, VHost, Protocol, Pid, + Infos); + {refused, _M, _A} -> {error, auth_failure} + end; + false -> {error, broker_not_found_on_node} end. |