From 7bfd7cc2192f63e783f089bc82b5eb68a3bea57c Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Wed, 17 Aug 2022 14:01:33 +0300 Subject: [PATCH] Fix captcha HTTP request --- lib/plausible_web/captcha.ex | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/plausible_web/captcha.ex b/lib/plausible_web/captcha.ex index b05d607f4..bffde5634 100644 --- a/lib/plausible_web/captcha.ex +++ b/lib/plausible_web/captcha.ex @@ -17,12 +17,18 @@ defmodule PlausibleWeb.Captcha do res = HTTPClient.post( @verify_endpoint, - [], - {:form, [{"response", token}, {"secret", secret()}]} + [{"Content-Type", "application/x-www-form-urlencoded"}], + "response=#{token}&secret=#{secret()}" ) - json = Jason.decode!(res.body) - json["success"] + case res do + {:ok, %Finch.Response{status: 200, body: body}} -> + json = Jason.decode!(body) + json["success"] + + _ -> + false + end else true end