diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-12-11 09:46:26 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-12-11 09:46:26 +0300 |
commit | bd064fa3fc96dc765d9db4442073da51f14d593a (patch) | |
tree | f85dd79d9002976c7a511b6e5d3c77bb108d9977 /src/mod_legacy_auth.erl | |
parent | Include <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.erl | 7 |
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. |