aboutsummaryrefslogtreecommitdiff
path: root/src/mod_legacy_auth.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-12-11 09:46:26 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-12-11 09:46:26 +0300
commitbd064fa3fc96dc765d9db4442073da51f14d593a (patch)
treef85dd79d9002976c7a511b6e5d3c77bb108d9977 /src/mod_legacy_auth.erl
parentInclude <x/> tag in presence errors related to nick change (diff)
Use xmpp:try_subtag/2 wherever possible
Diffstat (limited to '')
-rw-r--r--src/mod_legacy_auth.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mod_legacy_auth.erl b/src/mod_legacy_auth.erl
index 722a05738..0ae3253c9 100644
--- a/src/mod_legacy_auth.erl
+++ b/src/mod_legacy_auth.erl
@@ -61,11 +61,16 @@ mod_opt_type(_) ->
c2s_state() | {stop, c2s_state()}.
c2s_unauthenticated_packet(State, #iq{type = T, sub_els = [_]} = IQ)
when T == get; T == set ->
- case xmpp:get_subtag(IQ, #legacy_auth{}) of
+ try xmpp:try_subtag(IQ, #legacy_auth{}) of
#legacy_auth{} = Auth ->
{stop, authenticate(State, xmpp:set_els(IQ, [Auth]))};
false ->
State
+ catch _:{xmpp_codec, Why} ->
+ Txt = xmpp:io_format_error(Why),
+ Lang = maps:get(lang, State),
+ Err = xmpp:make_error(IQ, xmpp:error_bad_request(Txt, Lang)),
+ {stop, ejabberd_c2s:send(State, Err)}
end;
c2s_unauthenticated_packet(State, _) ->
State.