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 | 809e2445dfd1f61e7922c168db1af49dbeb5f873 (patch) | |
| tree | ec61b7045fdfa94d7077cc92c437699e14534004 /src | |
| parent | 17499fa2429c349c9bd2996e3d7b677f61fa5267 (diff) | |
| download | rabbitmq-server-git-809e2445dfd1f61e7922c168db1af49dbeb5f873.tar.gz | |
refactor: replace <module>:F with funs
the former is evil
Diffstat (limited to 'src')
| -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 53144f3fa4..c18b50235d 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. |
