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