diff --git a/yesod-auth/ChangeLog.md b/yesod-auth/ChangeLog.md index 5f6b5716..263ce819 100644 --- a/yesod-auth/ChangeLog.md +++ b/yesod-auth/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.4.3 + +* Added means to fetch user's Google profile [#936](https://github.com/yesodweb/yesod/pull/936) + ## 1.4.2 * Perform `onLogout` before session cleaning [#923](https://github.com/yesodweb/yesod/pull/923) diff --git a/yesod-auth/Yesod/Auth/GoogleEmail2.hs b/yesod-auth/Yesod/Auth/GoogleEmail2.hs index 8dfe13d4..7a1c1824 100644 --- a/yesod-auth/Yesod/Auth/GoogleEmail2.hs +++ b/yesod-auth/Yesod/Auth/GoogleEmail2.hs @@ -125,6 +125,8 @@ authGoogleEmail = authPlugin False -- | An alternative version which stores user access token in the session -- variable. Use it if you want to request user's profile from your app. +-- +-- Since 1.4.3 authGoogleEmailSaveToken :: YesodAuth m => Text -- ^ client ID -> Text -- ^ client secret @@ -228,6 +230,8 @@ authPlugin storeToken clientID clientSecret = -- | Allows to fetch information about a user from Google's API. -- In case of parsing error returns 'Nothing'. -- Will throw 'HttpException' in case of network problems or error response code. +-- +-- Since 1.4.3 getPerson :: Manager -> Token -> HandlerT site IO (Maybe Person) getPerson manager token = parseMaybe parseJSON <$> getPersonValue manager token @@ -248,6 +252,8 @@ getPersonValue manager token = do -- The token gets saved into the session storage only if you use -- 'authGoogleEmailSaveToken'. -- You can acquire saved token with 'getUserAccessToken'. +-- +-- Since 1.4.3 data Token = Token { accessToken :: Text , tokenType :: Text } deriving (Show, Eq) @@ -259,6 +265,8 @@ instance FromJSON Token where -------------------------------------------------------------------------------- -- | Gender of the person +-- +-- Since 1.4.3 data Gender = Male | Female | OtherGender deriving (Show, Eq) instance FromJSON Gender where @@ -269,6 +277,8 @@ instance FromJSON Gender where -------------------------------------------------------------------------------- -- | URIs specified in the person's profile +-- +-- Since 1.4.3 data PersonURI = PersonURI { uriLabel :: Maybe Text , uriValue :: Maybe Text @@ -282,6 +292,8 @@ instance FromJSON PersonURI where -------------------------------------------------------------------------------- -- | The type of URI +-- +-- Since 1.4.3 data PersonURIType = OtherProfile -- ^ URI for another profile | Contributor -- ^ URI to a site for which this person is a contributor | Website -- ^ URI for this Google+ Page's primary website @@ -299,6 +311,8 @@ instance FromJSON PersonURIType where -------------------------------------------------------------------------------- -- | Current or past organizations with which this person is associated +-- +-- Since 1.4.3 data Organization = Organization { orgName :: Maybe Text -- ^ The person's job title or role within the organization @@ -324,6 +338,8 @@ instance FromJSON Organization where -------------------------------------------------------------------------------- -- | The type of an organization +-- +-- Since 1.4.3 data OrganizationType = Work | School | OrganizationType Text -- ^ Something else @@ -336,6 +352,8 @@ instance FromJSON OrganizationType where -------------------------------------------------------------------------------- -- | A place where the person has lived or is living at the moment. +-- +-- Since 1.4.3 data Place = Place { -- | A place where this person has lived. For example: "Seattle, WA", "Near Toronto". placeValue :: Maybe Text @@ -348,6 +366,8 @@ instance FromJSON Place where -------------------------------------------------------------------------------- -- | Individual components of a name +-- +-- Since 1.4.3 data Name = Name { -- | The full name of this person, including middle names, suffixes, etc nameFormatted :: Maybe Text @@ -373,6 +393,8 @@ instance FromJSON Name where -------------------------------------------------------------------------------- -- | The person's relationship status. +-- +-- Since 1.4.3 data RelationshipStatus = Single -- ^ Person is single | InRelationship -- ^ Person is in a relationship | Engaged -- ^ Person is engaged @@ -400,6 +422,8 @@ instance FromJSON RelationshipStatus where -------------------------------------------------------------------------------- -- | The URI of the person's profile photo. +-- +-- Since 1.4.3 newtype PersonImage = PersonImage { imageUri :: Text } deriving (Show, Eq) instance FromJSON PersonImage where @@ -408,6 +432,8 @@ instance FromJSON PersonImage where -- | @resizePersonImage img 30@ would set query part to @?sz=30@ which would resize -- the image under the URI. If for some reason you need to modify the query -- part, you should do it after resizing. +-- +-- Since 1.4.3 resizePersonImage :: PersonImage -> Int -> PersonImage resizePersonImage (PersonImage uri) size = PersonImage $ uri `mappend` "?sz=" `mappend` T.pack (show size) @@ -415,6 +441,8 @@ resizePersonImage (PersonImage uri) size = -------------------------------------------------------------------------------- -- | Information about the user -- Full description of the resource https://developers.google.com/+/api/latest/people +-- +-- Since 1.4.3 data Person = Person { personId :: Text -- | The name of this person, which is suitable for display @@ -483,6 +511,8 @@ instance FromJSON Person where -------------------------------------------------------------------------------- -- | Person's email +-- +-- Since 1.4.3 data Email = Email { emailValue :: Text , emailType :: EmailType @@ -496,6 +526,8 @@ instance FromJSON Email where -------------------------------------------------------------------------------- -- | Type of email +-- +-- Since 1.4.3 data EmailType = EmailAccount -- ^ Google account email address | EmailHome -- ^ Home email address | EmailWork -- ^ Work email adress diff --git a/yesod-auth/yesod-auth.cabal b/yesod-auth/yesod-auth.cabal index 3299b6b2..d9813ff8 100644 --- a/yesod-auth/yesod-auth.cabal +++ b/yesod-auth/yesod-auth.cabal @@ -1,5 +1,5 @@ name: yesod-auth -version: 1.4.2 +version: 1.4.3 license: MIT license-file: LICENSE author: Michael Snoyman, Patrick Brisbin