yesod-auth-oauth2 0.0.4 → 0.0.5
raw patch · 3 files changed
+15/−12 lines, 3 filesdep ~hoauth2dep ~yesod-authdep ~yesod-core
Dependency ranges changed: hoauth2, yesod-auth, yesod-core
Files
- Yesod/Auth/OAuth2.hs +6/−4
- Yesod/Auth/OAuth2/Learn.hs +5/−4
- yesod-auth-oauth2.cabal +4/−4
Yesod/Auth/OAuth2.hs view
@@ -22,6 +22,7 @@ import Data.Text.Encoding.Error (lenientDecode) import Data.Typeable import Network.OAuth.OAuth2+import Network.HTTP.Conduit(Manager) import Yesod.Auth import Yesod.Core import Yesod.Form@@ -41,7 +42,7 @@ authOAuth2 :: YesodAuth m => Text -- ^ Service name -> OAuth2 -- ^ Service details- -> (AccessToken -> IO (Creds m))+ -> (Manager -> AccessToken -> IO (Creds m)) -- ^ This function defines how to take an @'AccessToken'@ and -- retrieve additional information about the user, to be -- set in the session as @'Creds'@. Usually this means a@@ -64,12 +65,13 @@ dispatch "GET" ["callback"] = do code <- lift $ runInputGet $ ireq textField "code" oauth' <- withCallback- result <- liftIO $ fetchAccessToken oauth' (encodeUtf8 code)+ master <- lift getYesod+ result <- liftIO $ fetchAccessToken (authHttpManager master) oauth' (encodeUtf8 code) case result of Left _ -> permissionDenied "Unable to retreive OAuth2 token" Right token -> do- creds <- liftIO $ getCreds token- lift $ setCreds True creds+ creds <- liftIO $ getCreds (authHttpManager master) token+ lift $ setCredsRedirect creds dispatch _ _ = notFound
Yesod/Auth/OAuth2/Learn.hs view
@@ -20,6 +20,7 @@ import Data.Text.Encoding (encodeUtf8) import Yesod.Auth import Yesod.Auth.OAuth2+import Network.HTTP.Conduit(Manager) import qualified Data.Text as T data LearnUser = LearnUser@@ -60,10 +61,10 @@ }) fetchLearnProfile -fetchLearnProfile :: AccessToken -> IO (Creds m)-fetchLearnProfile token = do- result <- authGetJSON token "http://learn.thoughtbot.com/api/v1/me.json"-+fetchLearnProfile :: Manager -> AccessToken -> IO (Creds m)+fetchLearnProfile manager token = do+ result <- authGetJSON manager token "http://learn.thoughtbot.com/api/v1/me.json"+ case result of Right (LearnResponse user) -> return $ toCreds user Left err -> throwIO $ InvalidProfileResponse "learn" err
yesod-auth-oauth2.cabal view
@@ -1,5 +1,5 @@ name: yesod-auth-oauth2-version: 0.0.4+version: 0.0.5 license: BSD3 license-file: LICENSE author: Tom Streller@@ -25,12 +25,12 @@ , http-conduit >= 2.0 && < 3.0 , http-types >= 0.8 && < 0.9 , aeson >= 0.6 && < 0.8- , yesod-core >= 1.2 && < 1.3- , yesod-auth >= 1.2 && < 1.3+ , yesod-core >= 1.2 && < 1.4+ , yesod-auth >= 1.3 && < 1.4 , text >= 0.7 && < 2.0 , yesod-form >= 1.3 && < 1.4 , transformers >= 0.2.2 && < 0.4- , hoauth2 >= 0.3.6 && < 0.4+ , hoauth2 >= 0.4.1 && < 0.5 , lifted-base >= 0.2 && < 0.4 exposed-modules: Yesod.Auth.OAuth2