From 41eda086a1a947992d76b0f4283e947fac211d90 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sat, 27 Jan 2018 12:24:02 -0500 Subject: [PATCH] Fixup Google documentation --- src/Yesod/Auth/OAuth2/Google.hs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Yesod/Auth/OAuth2/Google.hs b/src/Yesod/Auth/OAuth2/Google.hs index 6e355a9..46932b0 100644 --- a/src/Yesod/Auth/OAuth2/Google.hs +++ b/src/Yesod/Auth/OAuth2/Google.hs @@ -6,25 +6,23 @@ -- * Authenticates against Google -- * Uses Google user id as credentials identifier -- --- If you were previously relying on the ability to parse email as the creds --- identifier, you can still do that by overriding it in the creds returned by --- the plugin. For example: +-- If you were previously relying on email as the creds identifier, you can +-- still do that (and more) by overriding it in the creds returned by the plugin +-- with any value read out of the new @userResponseJSON@ key in @'credsExtra'@. -- --- > -- --- > -- NOTE: proper use of Maybe/Either omitted for clarity. --- > -- +-- For example: +-- +-- > data User = User { userEmail :: Text } -- > --- > parseEmail :: ByteString -> Text --- > parseEmail = undefined +-- > instance FromJSON User where -- you know... -- > -- > authenticate creds = do --- > let userResponseJSON = fromJust $ lookup "userResponseJSON" credsExtra creds --- > userEmail = parseEmail userResponseJSON --- > updatedCreds = creds { credsIdent = userEmail } +-- > -- 'getUserResponse' provided by "Yesod.Auth.OAuth" module +-- > let Right email = userEmail <$> getUserResponse creds +-- > updatedCreds = creds { credsIdent = email } -- > -- > -- continue normally with updatedCreds -- --- module Yesod.Auth.OAuth2.Google ( oauth2Google , oauth2GoogleScoped