packages feed

yesod-recaptcha 1.2.3 → 1.2.3.2

raw patch · 2 files changed

+34/−37 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

src/Yesod/ReCAPTCHA.hs view
@@ -166,45 +166,42 @@       manager    <- YA.authHttpManager <$> YC.getYesod       privateKey <- recaptchaPrivateKey       sockaddr   <- W.remoteHost <$> YC.waiRequest-      case sockaddr of-        HS.SockAddrUnix _ -> do-          $(YC.logError) $ "Yesod.ReCAPTCHA: Couldn't find out remote IP, \+      remoteip <- case sockaddr of+                       HS.SockAddrInet _ hostAddr ->+                         return . show $ NI.IPv4 hostAddr+                       HS.SockAddrInet6 _ _ (w1, w2, w3, w4) _ ->+                         return . show $ NI.IPv6 w1 w2 w3 w4+                       _ -> do+                          $(YC.logError) $ "Yesod.ReCAPTCHA: Couldn't find out remote IP, \                            \are you using a reverse proxy?  If yes, then \                            \please file a bug report at \                            \<https://github.com/meteficha/yesod-recaptcha>."-          fail "Could not find remote IP address for reCAPTCHA."-        _ -> do-          let remoteip = case sockaddr of-                           HS.SockAddrInet _ hostAddr ->-                             show $ NI.IPv4 hostAddr-                           HS.SockAddrInet6 _ _ (w1, w2, w3, w4) _ ->-                             show $ NI.IPv6 w1 w2 w3 w4-                           HS.SockAddrUnix _ -> error "ReCAPTCHA.check"-              req = D.def-                      { H.method      = HT.methodPost-                      , H.host        = "www.google.com"-                      , H.path        = "/recaptcha/api/verify"-                      , H.queryString = HT.renderSimpleQuery False query-                      }-              query = [ ("privatekey", TE.encodeUtf8 privateKey)-                      , ("remoteip",   B8.pack       remoteip)-                      , ("challenge",  TE.encodeUtf8 challenge)-                      , ("response",   TE.encodeUtf8 response)-                      ]-          eresp <- E.try $ R.runResourceT $ H.httpLbs req manager-          case (L8.lines . H.responseBody) <$> eresp of-            Right ("true":_)      -> return Ok-            Right ("false":why:_) -> return . Error . TL.toStrict $-                                     TLE.decodeUtf8With TEE.lenientDecode why-            Right other -> do-              $(YC.logError) $ T.concat [ "Yesod.ReCAPTCHA: could not parse "-                                        , T.pack (show other) ]-              return (Error "recaptcha-not-reachable")-            Left exc -> do-              $(YC.logError) $ T.concat [ "Yesod.ReCAPTCHA: could not contact server ("-                                        , T.pack (show (exc :: E.SomeException))-                                        , ")" ]-              return (Error "recaptcha-not-reachable")+                          fail "Could not find remote IP address for reCAPTCHA."+      let req = D.def+                  { H.method      = HT.methodPost+                  , H.host        = "www.google.com"+                  , H.path        = "/recaptcha/api/verify"+                  , H.queryString = HT.renderSimpleQuery False query+                  }+          query = [ ("privatekey", TE.encodeUtf8 privateKey)+                  , ("remoteip",   B8.pack       remoteip)+                  , ("challenge",  TE.encodeUtf8 challenge)+                  , ("response",   TE.encodeUtf8 response)+                  ]+      eresp <- E.try $ R.runResourceT $ H.httpLbs req manager+      case (L8.lines . H.responseBody) <$> eresp of+        Right ("true":_)      -> return Ok+        Right ("false":why:_) -> return . Error . TL.toStrict $+                                 TLE.decodeUtf8With TEE.lenientDecode why+        Right other -> do+          $(YC.logError) $ T.concat [ "Yesod.ReCAPTCHA: could not parse "+                                    , T.pack (show other) ]+          return (Error "recaptcha-not-reachable")+        Left exc -> do+          $(YC.logError) $ T.concat [ "Yesod.ReCAPTCHA: could not contact server ("+                                    , T.pack (show (exc :: E.SomeException))+                                    , ")" ]+          return (Error "recaptcha-not-reachable")   -- | See 'check'.
yesod-recaptcha.cabal view
@@ -1,5 +1,5 @@ Name:                yesod-recaptcha-Version:             1.2.3+Version:             1.2.3.2 Synopsis:            Dead simple support for reCAPTCHA on Yesod applications. Homepage:            https://github.com/prowdsponsor/yesod-recaptcha License:             BSD3