logout :: ByteString -> ByteString -> Maybe ByteString -> W.Application
logout key cookieName cookieDomain req resp = do
  let host = fromJust $ W.requestHeaderHost req
  case extractCookie key Nothing cookieName req of
    Nothing ->
      resp $ W.responseLBS found302 [(hLocation, "https://" <> host)] ""
    Just _ -> do
      let cookie =
            WC.def
              { WC.setCookieName = cookieName
              , WC.setCookieHttpOnly = True
              , WC.setCookiePath = Just "/"
              , WC.setCookieSameSite = Just WC.sameSiteStrict
              , WC.setCookieSecure = True
              , WC.setCookieValue = "goodbye"
              , WC.setCookieDomain = cookieDomain
              , WC.setCookieExpires =
                  Just . posixSecondsToUTCTime . realToFrac $ CTime 0
              }
      resp $
        W.responseLBS
          found302
          [ (hLocation, "https://" <> host)
          , ("Set-Cookie", toByteString $ WC.renderSetCookie cookie)
          ]
          ""
logout :: ByteString -> ByteString -> Maybe ByteString -> W.Application
logout key cookieName cookieDomain req resp = do
  let host = fromJust $ W.requestHeaderHost req
  case extractCookie key Nothing cookieName req of
    Nothing ->
      resp $ W.responseLBS found302 [(hLocation, "https://" <> host)] ""
    Just _ -> do
      let cookie =
            WC.def
              { WC.setCookieName = cookieName
              , WC.setCookieHttpOnly = True
              , WC.setCookiePath = Just "/"
              , WC.setCookieSameSite = Just WC.sameSiteStrict
              , WC.setCookieSecure = True
              , WC.setCookieValue = "goodbye"
              , WC.setCookieDomain = cookieDomain
              , WC.setCookieExpires =
                  Just . posixSecondsToUTCTime . realToFrac $ CTime 0
              }
      resp $
        W.responseLBS
          found302
          [ (hLocation, "https://" <> host)
          , ("Set-Cookie", toByteString $ WC.renderSetCookie cookie)
          ]
          ""
logout key cookieName cookieDomain req resp = do
  let host = fromJust $ W.requestHeaderHost req
  case extractCookie key Nothing cookieName req of
    Nothing ->
      resp $ W.responseLBS found302 [(hLocation, "https://" <> host)] ""
    Just _ -> do
      let cookie =
            WC.def
              { WC.setCookieName = cookieName
              , WC.setCookieHttpOnly = True
              , WC.setCookiePath = Just "/"
              , WC.setCookieSameSite = Just WC.sameSiteStrict
              , WC.setCookieSecure = True
              , WC.setCookieValue = "goodbye"
              , WC.setCookieDomain = cookieDomain
              , WC.setCookieExpires =
                  Just . posixSecondsToUTCTime . realToFrac $ CTime 0
              }
      resp $
        W.responseLBS
          found302
          [ (hLocation, "https://" <> host)
          , ("Set-Cookie", toByteString $ WC.renderSetCookie cookie)
          ]
          ""