Support aeson 2
This commit is contained in:
parent
2c498c14b2
commit
385d17dd94
@ -1,5 +1,9 @@
|
|||||||
# ChangeLog for yesod-auth
|
# ChangeLog for yesod-auth
|
||||||
|
|
||||||
|
## 1.6.10.5
|
||||||
|
|
||||||
|
* Add support for aeson 2
|
||||||
|
|
||||||
## 1.6.10.4
|
## 1.6.10.4
|
||||||
|
|
||||||
* Add support for GHC 9 [#1737](https://github.com/yesodweb/yesod/pull/1737)
|
* Add support for GHC 9 [#1737](https://github.com/yesodweb/yesod/pull/1737)
|
||||||
|
|||||||
@ -52,7 +52,6 @@ import Control.Monad.Trans.Maybe
|
|||||||
import UnliftIO (withRunInIO, MonadUnliftIO)
|
import UnliftIO (withRunInIO, MonadUnliftIO)
|
||||||
|
|
||||||
import Yesod.Auth.Routes
|
import Yesod.Auth.Routes
|
||||||
import Data.Aeson hiding (json)
|
|
||||||
import Data.Text.Encoding (decodeUtf8With)
|
import Data.Text.Encoding (decodeUtf8With)
|
||||||
import Data.Text.Encoding.Error (lenientDecode)
|
import Data.Text.Encoding.Error (lenientDecode)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
@ -452,7 +451,7 @@ $nothing
|
|||||||
<p>Not logged in.
|
<p>Not logged in.
|
||||||
|]
|
|]
|
||||||
jsonCreds creds =
|
jsonCreds creds =
|
||||||
Object $ Map.fromList
|
toJSON $ Map.fromList
|
||||||
[ (T.pack "logged_in", Bool $ maybe False (const True) creds)
|
[ (T.pack "logged_in", Bool $ maybe False (const True) creds)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,6 @@ import Data.Aeson.Types (FromJSON (parseJSON), parseEither,
|
|||||||
parseMaybe, withObject, withText)
|
parseMaybe, withObject, withText)
|
||||||
import Data.Conduit
|
import Data.Conduit
|
||||||
import Data.Conduit.Attoparsec (sinkParser)
|
import Data.Conduit.Attoparsec (sinkParser)
|
||||||
import qualified Data.HashMap.Strict as M
|
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Data.Monoid (mappend)
|
import Data.Monoid (mappend)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
@ -103,6 +102,13 @@ import Network.HTTP.Conduit (http)
|
|||||||
import Network.HTTP.Types (renderQueryText)
|
import Network.HTTP.Types (renderQueryText)
|
||||||
import System.IO.Unsafe (unsafePerformIO)
|
import System.IO.Unsafe (unsafePerformIO)
|
||||||
|
|
||||||
|
#if MIN_VERSION_aeson(2, 0, 0)
|
||||||
|
import qualified Data.Aeson.Key
|
||||||
|
import qualified Data.Aeson.KeyMap
|
||||||
|
#else
|
||||||
|
import qualified Data.HashMap.Strict as M
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
-- | Plugin identifier. This is used to identify the plugin used for
|
-- | Plugin identifier. This is used to identify the plugin used for
|
||||||
-- authentication. The 'credsPlugin' will contain this value when this
|
-- authentication. The 'credsPlugin' will contain this value when this
|
||||||
@ -587,9 +593,19 @@ instance FromJSON EmailType where
|
|||||||
_ -> EmailType t
|
_ -> EmailType t
|
||||||
|
|
||||||
allPersonInfo :: A.Value -> [(Text, Text)]
|
allPersonInfo :: A.Value -> [(Text, Text)]
|
||||||
allPersonInfo (A.Object o) = map enc $ M.toList o
|
allPersonInfo (A.Object o) = map enc $ mapToList o
|
||||||
where enc (key, A.String s) = (key, s)
|
where
|
||||||
enc (key, v) = (key, TL.toStrict $ TL.toLazyText $ A.encodeToTextBuilder v)
|
enc (key, A.String s) = (keyToText key, s)
|
||||||
|
enc (key, v) = (keyToText key, TL.toStrict $ TL.toLazyText $ A.encodeToTextBuilder v)
|
||||||
|
|
||||||
|
#if MIN_VERSION_aeson(2, 0, 0)
|
||||||
|
keyToText = Data.Aeson.Key.toText
|
||||||
|
mapToList = Data.Aeson.KeyMap.toList
|
||||||
|
#else
|
||||||
|
keyToText = id
|
||||||
|
mapToList = M.toList
|
||||||
|
#endif
|
||||||
|
|
||||||
allPersonInfo _ = []
|
allPersonInfo _ = []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
cabal-version: >=1.10
|
cabal-version: >=1.10
|
||||||
name: yesod-auth
|
name: yesod-auth
|
||||||
version: 1.6.10.4
|
version: 1.6.10.5
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman, Patrick Brisbin
|
author: Michael Snoyman, Patrick Brisbin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user