fix(stomp): fix anonymous not working
This commit is contained in:
parent
3d9054d25e
commit
d2b6a95484
|
@ -139,7 +139,7 @@ received(Frame = #stomp_frame{command = <<"SEND">>, headers = Headers}, State) -
|
||||||
end;
|
end;
|
||||||
|
|
||||||
received(#stomp_frame{command = <<"SUBSCRIBE">>, headers = Headers},
|
received(#stomp_frame{command = <<"SUBSCRIBE">>, headers = Headers},
|
||||||
State = #pstate{subscriptions = Subscriptions}) ->
|
State = #pstate{subscriptions = Subscriptions, login = Login}) ->
|
||||||
Id = header(<<"id">>, Headers),
|
Id = header(<<"id">>, Headers),
|
||||||
Topic = header(<<"destination">>, Headers),
|
Topic = header(<<"destination">>, Headers),
|
||||||
Ack = header(<<"ack">>, Headers, <<"auto">>),
|
Ack = header(<<"ack">>, Headers, <<"auto">>),
|
||||||
|
@ -147,7 +147,7 @@ received(#stomp_frame{command = <<"SUBSCRIBE">>, headers = Headers},
|
||||||
{Id, Topic, Ack} ->
|
{Id, Topic, Ack} ->
|
||||||
{ok, State};
|
{ok, State};
|
||||||
false ->
|
false ->
|
||||||
emqx_broker:subscribe(Topic),
|
emqx_broker:subscribe(Topic, Login),
|
||||||
{ok, State#pstate{subscriptions = [{Id, Topic, Ack}|Subscriptions]}}
|
{ok, State#pstate{subscriptions = [{Id, Topic, Ack}|Subscriptions]}}
|
||||||
end,
|
end,
|
||||||
maybe_send_receipt(receipt_id(Headers), State1);
|
maybe_send_receipt(receipt_id(Headers), State1);
|
||||||
|
@ -312,13 +312,15 @@ negotiate_version(Ver, [AcceptVer|_]) when Ver >= AcceptVer ->
|
||||||
negotiate_version(Ver, [_|T]) ->
|
negotiate_version(Ver, [_|T]) ->
|
||||||
negotiate_version(Ver, T).
|
negotiate_version(Ver, T).
|
||||||
|
|
||||||
check_login(undefined, _, AllowAnonymous, _) ->
|
check_login(Login, _, AllowAnonymous, _)
|
||||||
|
when Login == <<>>;
|
||||||
|
Login == undefined ->
|
||||||
AllowAnonymous;
|
AllowAnonymous;
|
||||||
check_login(_, _, _, undefined) ->
|
check_login(_, _, _, undefined) ->
|
||||||
false;
|
false;
|
||||||
check_login(Login, Passcode, _, DefaultUser) ->
|
check_login(Login, Passcode, _, DefaultUser) ->
|
||||||
case {list_to_binary(get_value(login, DefaultUser)),
|
case {iolist_to_binary(get_value(login, DefaultUser)),
|
||||||
list_to_binary(get_value(passcode, DefaultUser))} of
|
iolist_to_binary(get_value(passcode, DefaultUser))} of
|
||||||
{Login, Passcode} -> true;
|
{Login, Passcode} -> true;
|
||||||
{_, _ } -> false
|
{_, _ } -> false
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue