yesod-auth-oauth2/src/Yesod/Auth/OAuth2/UserId.hs
patrick brisbin b1181298ba
WIP: Provider interface
TODO: write detailed commit message / CHANGELOG.

Highlights:

- The "Provider" abstraction, which leads to
- Way tinier definitions, also aided by
- Stop fetching full profiles (#71)
- Drop GHC < 7.10 support (and CPP)
- Extract clarified Dispatch module
2018-01-23 10:33:29 -05:00

25 lines
696 B
Haskell

{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
module Yesod.Auth.OAuth2.UserId
( UserId(..)
, UserIdText(..)
) where
import Data.Aeson
import Data.Text (Text)
import Yesod.Auth.OAuth2.Provider (ToIdent(..))
-- | Parse-able type to use for responses with an integer @id@ field
newtype UserId = UserId Int
deriving ToIdent
instance FromJSON UserId where
parseJSON = withObject "User" $ \o -> UserId <$> o .: "id"
-- | Parse-able type to use for responses with a textual @id@ field
newtype UserIdText = UserIdText Text
deriving ToIdent
instance FromJSON UserIdText where
parseJSON = withObject "User" $ \o -> UserIdText <$> o .: "id"