Skip to content

Commit f18fdce

Browse files
Simplify further with a macro, suggested by @dumbbell
1 parent dca8178 commit f18fdce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/rabbit_auth_mechanism_amqplain.erl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ should_offer(_Sock) ->
4141
init(_Sock) ->
4242
[].
4343

44+
-define(IS_STRING_TYPE(Type), Type =:= longstr orelse Type =:= shortstr).
45+
4446
handle_response(Response, _State) ->
4547
LoginTable = rabbit_binary_parser:parse_table(Response),
4648
case {lists:keysearch(<<"LOGIN">>, 1, LoginTable),
4749
lists:keysearch(<<"PASSWORD">>, 1, LoginTable)} of
4850
{{value, {_, UserType, User}},
49-
{value, {_, PassType, Pass}}} when UserType =:= longstr orelse UserType =:= shortstr;
50-
PassType =:= longstr orelse PassType =:= shortstr ->
51+
{value, {_, PassType, Pass}}} when ?IS_STRING_TYPE(UserType);
52+
?IS_STRING_TYPE(PassType) ->
5153
rabbit_access_control:check_user_pass_login(User, Pass);
5254
{{value, {_, _UserType, _User}},
5355
{value, {_, _PassType, _Pass}}} ->

0 commit comments

Comments
 (0)