authenticate 0.10.3.1 → 0.10.4
raw patch · 3 files changed
+36/−11 lines, 3 filesnew-uploaderPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Web.Authenticate.Facebook: getForwardUrlParams :: Facebook -> [(Text, Text)] -> Text
+ Web.Authenticate.Facebook: getForwardUrlWithState :: Facebook -> [Text] -> Text -> Text
+ Web.Authenticate.Facebook: getLogoutUrl :: AccessToken -> Text -> Text
Files
- Web/Authenticate/Facebook.hs +29/−7
- Web/Authenticate/OAuth.hs +4/−1
- authenticate.cabal +3/−3
Web/Authenticate/Facebook.hs view
@@ -4,10 +4,13 @@ module Web.Authenticate.Facebook ( Facebook (..) , AccessToken (..)+ , getForwardUrlParams+ , getForwardUrlWithState , getForwardUrl , getAccessToken , getGraphData , getGraphData_+ , getLogoutUrl ) where import Network.HTTP.Enumerator@@ -27,6 +30,7 @@ import Network.HTTP.Types (renderQueryText) import Data.Monoid (mappend) import Data.ByteString (ByteString)+import Control.Arrow ((***)) data Facebook = Facebook { facebookClientId :: Text@@ -38,19 +42,28 @@ newtype AccessToken = AccessToken { unAccessToken :: Text } deriving (Show, Eq, Read, Ord, Data, Typeable) -getForwardUrl :: Facebook -> [Text] -> Text-getForwardUrl fb perms =+getForwardUrlParams :: Facebook -> [(Text, Text)] -> Text+getForwardUrlParams fb params = TE.decodeUtf8 $ toByteString $ copyByteString "https://graph.facebook.com/oauth/authorize" `mappend` renderQueryText True- ( ("client_id", Just $ facebookClientId fb)- : ("redirect_uri", Just $ facebookRedirectUri fb)- : if null perms- then []- else [("scope", Just $ T.intercalate "," perms)])+ ( ("client_id", Just $ facebookClientId fb)+ : ("redirect_uri", Just $ facebookRedirectUri fb)+ : map (id *** Just) params) +-- Internal function used to simplify getForwardUrl & getForwardUrlWithState+getForwardUrlWithExtra_ :: Facebook -> [Text] -> [(Text, Text)] -> Text+getForwardUrlWithExtra_ fb perms extra = getForwardUrlParams fb $ (if null perms+ then id+ else (("scope", T.intercalate "," perms):)) extra +getForwardUrlWithState :: Facebook -> [Text] -> Text -> Text+getForwardUrlWithState fb perms state = getForwardUrlWithExtra_ fb perms [("state", state)]++getForwardUrl :: Facebook -> [Text] -> Text+getForwardUrl fb perms = getForwardUrlWithExtra_ fb perms []+ accessTokenUrl :: Facebook -> Text -> ByteString accessTokenUrl fb code = toByteString $@@ -91,3 +104,12 @@ data InvalidJsonException = InvalidJsonException String deriving (Show, Typeable) instance Exception InvalidJsonException++-- | Logs out the user from their Facebook session.+getLogoutUrl :: AccessToken+ -> Text -- ^ URL the user should be directed to in your site domain.+ -> Text -- ^ Logout URL in @https://www.facebook.com/@.+getLogoutUrl (AccessToken s) next =+ TE.decodeUtf8 $ toByteString $+ copyByteString "https://www.facebook.com/logout.php"+ `mappend` renderQueryText True [("next", Just next), ("access_token", Just s)]
Web/Authenticate/OAuth.hs view
@@ -128,7 +128,10 @@ authorizeUrl :: OAuth -- ^ OAuth Application -> Credential -- ^ Temporary Credential (Request Token & Secret) -> String -- ^ URL to authorize-authorizeUrl oa cr = oauthAuthorizeUri oa ++ BS.unpack (renderSimpleQuery True [("oauth_token", token cr)])+authorizeUrl oa cr = oauthAuthorizeUri oa ++ BS.unpack (renderSimpleQuery True queries)+ where queries = case oauthCallback oa of+ Nothing -> [("oauth_token", token cr)]+ Just callback -> [("oauth_token", token cr), ("oauth_callback", callback)] -- | Get Access token. getAccessToken, getTokenCredential
authenticate.cabal view
@@ -1,5 +1,5 @@ name: authenticate-version: 0.10.3.1+version: 0.10.4 license: BSD3 license-file: LICENSE author: Michael Snoyman, Hiromi Ishii, Arash Rouhani@@ -11,7 +11,7 @@ stability: Stable cabal-version: >= 1.6 build-type: Simple-homepage: http://github.com/snoyberg/authenticate/tree/master+homepage: http://github.com/yesodweb/authenticate library build-depends: base >= 4 && < 5,@@ -54,4 +54,4 @@ source-repository head type: git- location: git://github.com/snoyberg/authenticate.git+ location: git://github.com/yesodweb/authenticate.git