Skip to content

Commit

Permalink
Make the server catch when the response from twitter has been denied.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdepillabout committed Jun 28, 2018
1 parent 651ae8a commit cc51574
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/GoatGuardian.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Network.HTTP.Conduit (HttpException, Manager, parseRequest, newManager, t
import qualified Network.HTTP.Conduit as HTTPClient
import Network.HTTP.ReverseProxy
import Network.HTTP.Types.Header (hCookie, hLocation, hSetCookie)
import Network.HTTP.Types.Status (status302, status404, status500)
import Network.HTTP.Types.Status (status302, status403, status404, status500)
import Network.Wai (Request, Response, ResponseReceived, pathInfo, queryString, requestHeaders, responseLBS)
import Network.Wai.Handler.Warp
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
Expand Down Expand Up @@ -233,12 +233,22 @@ handleTwitterCallback req = do
pure (reqToken, reqVerifier)
case maybeParams of
Nothing -> do
let resp =
responseLBS
status500
[]
"<p>callback response from twitter didn't have oauth_token or oauth_verifier</p>"
pure $ WPRResponse resp
let deniedParam = join $ lookup "denied" (queryString req)
case deniedParam of
Nothing -> do
let resp =
responseLBS
status500
[]
"<p>callback response from twitter didn't have oauth_token or oauth_verifier or denied</p>"
pure $ WPRResponse resp
Just _ -> do
let resp =
responseLBS
status403
[]
"<p>call response from twitter was denied</p>"
pure $ WPRResponse resp
Just (reqToken, reqVerifier) -> do
maybeTempToken <-
TonaDb.run $
Expand Down

0 comments on commit cc51574

Please sign in to comment.