]> granicus.if.org Git - ejabberd/commitdiff
Handle ejabberd_captcha error reports in mod_register_web (#2553)
authorBadlop <badlop@process-one.net>
Thu, 2 Aug 2018 16:36:41 +0000 (18:36 +0200)
committerBadlop <badlop@process-one.net>
Thu, 2 Aug 2018 16:36:41 +0000 (18:36 +0200)
src/mod_register_web.erl

index 7bda0e67d0eef5882e4b9f1fc926138ee39305a0..ae659ddc81fc1410ac17dcba62ff94076acd7c95 100644 (file)
@@ -222,7 +222,16 @@ index_page(Lang) ->
 %%%----------------------------------------------------------------------
 
 form_new_get(Host, Lang, IP) ->
-    CaptchaEls = build_captcha_li_list(Lang, IP),
+    try build_captcha_li_list(Lang, IP) of
+       CaptchaEls ->
+           form_new_get2(Host, Lang, CaptchaEls)
+       catch
+           throw:Result ->
+               ?DEBUG("Unexpected result when creating a captcha: ~p", [Result]),
+               ejabberd_web:error(not_allowed)
+    end.
+
+form_new_get2(Host, Lang, CaptchaEls) ->
     HeadEls = [meta(),
               ?XCT(<<"title">>,
                    <<"Register a Jabber account">>),
@@ -360,7 +369,7 @@ build_captcha_li_list2(Lang, IP) ->
              ejabberd_captcha:build_captcha_html(Id, Lang),
          [?XE(<<"li">>,
               [CText, ?C(<<" ">>), CId, CKey, ?BR, CImg])];
-      _ -> []
+      Error -> throw(Error)
     end.
 
 %%%----------------------------------------------------------------------