Merge pull request #1345 from psibi/export-pid

Export plugin identifier for GoogleEmail2 module
This commit is contained in:
Michael Snoyman 2017-02-07 14:21:59 +02:00 committed by GitHub
commit 958bc58153
2 changed files with 24 additions and 17 deletions

View File

@ -1,6 +1,7 @@
## 1.4.17 ## 1.4.17
* Add Show instance for user credentials `Creds` * Add Show instance for user credentials `Creds`
* Export pid type for identifying plugin
## 1.4.16 ## 1.4.16

View File

@ -22,7 +22,7 @@
-- --
-- * Enable the Google+ API. -- * Enable the Google+ API.
-- --
-- Since 1.3.1 -- @since 1.3.1
module Yesod.Auth.GoogleEmail2 module Yesod.Auth.GoogleEmail2
( -- * Authentication handlers ( -- * Authentication handlers
authGoogleEmail authGoogleEmail
@ -46,6 +46,8 @@ module Yesod.Auth.GoogleEmail2
, Place(..) , Place(..)
, Email(..) , Email(..)
, EmailType(..) , EmailType(..)
-- * Other functions
, pid
) where ) where
import Yesod.Auth (Auth, AuthPlugin (AuthPlugin), import Yesod.Auth (Auth, AuthPlugin (AuthPlugin),
@ -95,6 +97,10 @@ import Network.HTTP.Types (renderQueryText)
import System.IO.Unsafe (unsafePerformIO) import System.IO.Unsafe (unsafePerformIO)
-- | Plugin identifier. This is used to identify the plugin used for
-- authentication. The 'credsPlugin' will contain this value when this
-- plugin is used for authentication.
-- @since 1.4.17
pid :: Text pid :: Text
pid = "googleemail2" pid = "googleemail2"
@ -135,7 +141,7 @@ authGoogleEmail = authPlugin False
-- | An alternative version which stores user access token in the session -- | 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. -- variable. Use it if you want to request user's profile from your app.
-- --
-- Since 1.4.3 -- @since 1.4.3
authGoogleEmailSaveToken :: YesodAuth m authGoogleEmailSaveToken :: YesodAuth m
=> Text -- ^ client ID => Text -- ^ client ID
-> Text -- ^ client secret -> Text -- ^ client secret
@ -262,7 +268,7 @@ makeHttpRequest req = lift $
-- In case of parsing error returns 'Nothing'. -- In case of parsing error returns 'Nothing'.
-- Will throw 'HttpException' in case of network problems or error response code. -- Will throw 'HttpException' in case of network problems or error response code.
-- --
-- Since 1.4.3 -- @since 1.4.3
getPerson :: Manager -> Token -> HandlerT site IO (Maybe Person) getPerson :: Manager -> Token -> HandlerT site IO (Maybe Person)
getPerson manager token = parseMaybe parseJSON <$> (do getPerson manager token = parseMaybe parseJSON <$> (do
req <- personValueRequest token req <- personValueRequest token
@ -291,7 +297,7 @@ personValueRequest token = do
-- 'authGoogleEmailSaveToken'. -- 'authGoogleEmailSaveToken'.
-- You can acquire saved token with 'getUserAccessToken'. -- You can acquire saved token with 'getUserAccessToken'.
-- --
-- Since 1.4.3 -- @since 1.4.3
data Token = Token { accessToken :: Text data Token = Token { accessToken :: Text
, tokenType :: Text , tokenType :: Text
} deriving (Show, Eq) } deriving (Show, Eq)
@ -304,7 +310,7 @@ instance FromJSON Token where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Gender of the person -- | Gender of the person
-- --
-- Since 1.4.3 -- @since 1.4.3
data Gender = Male | Female | OtherGender deriving (Show, Eq) data Gender = Male | Female | OtherGender deriving (Show, Eq)
instance FromJSON Gender where instance FromJSON Gender where
@ -316,7 +322,7 @@ instance FromJSON Gender where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | URIs specified in the person's profile -- | URIs specified in the person's profile
-- --
-- Since 1.4.3 -- @since 1.4.3
data PersonURI = data PersonURI =
PersonURI { uriLabel :: Maybe Text PersonURI { uriLabel :: Maybe Text
, uriValue :: Maybe Text , uriValue :: Maybe Text
@ -331,7 +337,7 @@ instance FromJSON PersonURI where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | The type of URI -- | The type of URI
-- --
-- Since 1.4.3 -- @since 1.4.3
data PersonURIType = OtherProfile -- ^ URI for another profile data PersonURIType = OtherProfile -- ^ URI for another profile
| Contributor -- ^ URI to a site for which this person is a contributor | Contributor -- ^ URI to a site for which this person is a contributor
| Website -- ^ URI for this Google+ Page's primary website | Website -- ^ URI for this Google+ Page's primary website
@ -350,7 +356,7 @@ instance FromJSON PersonURIType where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Current or past organizations with which this person is associated -- | Current or past organizations with which this person is associated
-- --
-- Since 1.4.3 -- @since 1.4.3
data Organization = data Organization =
Organization { orgName :: Maybe Text Organization { orgName :: Maybe Text
-- ^ The person's job title or role within the organization -- ^ The person's job title or role within the organization
@ -377,7 +383,7 @@ instance FromJSON Organization where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | The type of an organization -- | The type of an organization
-- --
-- Since 1.4.3 -- @since 1.4.3
data OrganizationType = Work data OrganizationType = Work
| School | School
| OrganizationType Text -- ^ Something else | OrganizationType Text -- ^ Something else
@ -391,7 +397,7 @@ instance FromJSON OrganizationType where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | A place where the person has lived or is living at the moment. -- | A place where the person has lived or is living at the moment.
-- --
-- Since 1.4.3 -- @since 1.4.3
data Place = data Place =
Place { -- | A place where this person has lived. For example: "Seattle, WA", "Near Toronto". Place { -- | A place where this person has lived. For example: "Seattle, WA", "Near Toronto".
placeValue :: Maybe Text placeValue :: Maybe Text
@ -405,7 +411,7 @@ instance FromJSON Place where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Individual components of a name -- | Individual components of a name
-- --
-- Since 1.4.3 -- @since 1.4.3
data Name = data Name =
Name { -- | The full name of this person, including middle names, suffixes, etc Name { -- | The full name of this person, including middle names, suffixes, etc
nameFormatted :: Maybe Text nameFormatted :: Maybe Text
@ -432,7 +438,7 @@ instance FromJSON Name where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | The person's relationship status. -- | The person's relationship status.
-- --
-- Since 1.4.3 -- @since 1.4.3
data RelationshipStatus = Single -- ^ Person is single data RelationshipStatus = Single -- ^ Person is single
| InRelationship -- ^ Person is in a relationship | InRelationship -- ^ Person is in a relationship
| Engaged -- ^ Person is engaged | Engaged -- ^ Person is engaged
@ -461,7 +467,7 @@ instance FromJSON RelationshipStatus where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | The URI of the person's profile photo. -- | The URI of the person's profile photo.
-- --
-- Since 1.4.3 -- @since 1.4.3
newtype PersonImage = PersonImage { imageUri :: Text } deriving (Show, Eq) newtype PersonImage = PersonImage { imageUri :: Text } deriving (Show, Eq)
instance FromJSON PersonImage where instance FromJSON PersonImage where
@ -471,7 +477,7 @@ instance FromJSON PersonImage where
-- the image under the URI. If for some reason you need to modify the query -- the image under the URI. If for some reason you need to modify the query
-- part, you should do it after resizing. -- part, you should do it after resizing.
-- --
-- Since 1.4.3 -- @since 1.4.3
resizePersonImage :: PersonImage -> Int -> PersonImage resizePersonImage :: PersonImage -> Int -> PersonImage
resizePersonImage (PersonImage uri) size = resizePersonImage (PersonImage uri) size =
PersonImage $ uri `mappend` "?sz=" `mappend` T.pack (show size) PersonImage $ uri `mappend` "?sz=" `mappend` T.pack (show size)
@ -480,7 +486,7 @@ resizePersonImage (PersonImage uri) size =
-- | Information about the user -- | Information about the user
-- Full description of the resource https://developers.google.com/+/api/latest/people -- Full description of the resource https://developers.google.com/+/api/latest/people
-- --
-- Since 1.4.3 -- @since 1.4.3
data Person = Person data Person = Person
{ personId :: Text { personId :: Text
-- | The name of this person, which is suitable for display -- | The name of this person, which is suitable for display
@ -550,7 +556,7 @@ instance FromJSON Person where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Person's email -- | Person's email
-- --
-- Since 1.4.3 -- @since 1.4.3
data Email = Email data Email = Email
{ emailValue :: Text { emailValue :: Text
, emailType :: EmailType , emailType :: EmailType
@ -565,7 +571,7 @@ instance FromJSON Email where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Type of email -- | Type of email
-- --
-- Since 1.4.3 -- @since 1.4.3
data EmailType = EmailAccount -- ^ Google account email address data EmailType = EmailAccount -- ^ Google account email address
| EmailHome -- ^ Home email address | EmailHome -- ^ Home email address
| EmailWork -- ^ Work email adress | EmailWork -- ^ Work email adress