yesod-auth 1.1.2 → 1.1.2.1
raw patch · 3 files changed
+61/−7 lines, 3 filesdep ~persistentdep ~persistent-template
Dependency ranges changed: persistent, persistent-template
Files
- Yesod/Auth.hs +13/−0
- Yesod/Auth/HashDB.hs +45/−4
- yesod-auth.cabal +3/−3
Yesod/Auth.hs view
@@ -233,10 +233,17 @@ ap:_ -> apDispatch ap method pieces maybeAuth :: ( YesodAuth m+#if MIN_VERSION_persistent(1, 1, 0)+ , PersistMonadBackend (b (GHandler s m)) ~ PersistEntityBackend val , b ~ YesodPersistBackend m+ , Key val ~ AuthId m+ , PersistStore (b (GHandler s m))+#else+ , b ~ YesodPersistBackend m , b ~ PersistEntityBackend val , Key b val ~ AuthId m , PersistStore b (GHandler s m)+#endif , PersistEntity val , YesodPersist m ) => GHandler s m (Maybe (Entity val))@@ -250,9 +257,15 @@ requireAuth :: ( YesodAuth m , b ~ YesodPersistBackend m+#if MIN_VERSION_persistent(1, 1, 0)+ , PersistMonadBackend (b (GHandler s m)) ~ PersistEntityBackend val+ , Key val ~ AuthId m+ , PersistStore (b (GHandler s m))+#else , b ~ PersistEntityBackend val , Key b val ~ AuthId m , PersistStore b (GHandler s m)+#endif , PersistEntity val , YesodPersist m ) => GHandler s m (Entity val)
Yesod/Auth/HashDB.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GADTs #-}+{-# LANGUAGE CPP #-} ------------------------------------------------------------------------------- -- | -- Module : Yesod.Auth.HashDB@@ -133,14 +134,24 @@ -- | Given a user ID and password in plaintext, validate them against -- the database values. validateUser :: ( YesodPersist yesod+#if MIN_VERSION_persistent(1, 1, 0) , b ~ YesodPersistBackend yesod+ , PersistMonadBackend (b (GHandler sub yesod)) ~ PersistEntityBackend user+ , PersistUnique (b (GHandler sub yesod))+#else+ , b ~ YesodPersistBackend yesod , b ~ PersistEntityBackend user , PersistStore b (GHandler sub yesod) , PersistUnique b (GHandler sub yesod)+#endif , PersistEntity user , HashDBUser user ) => +#if MIN_VERSION_persistent(1, 1, 0)+ Unique user -- ^ User unique identifier+#else Unique user b -- ^ User unique identifier+#endif -> Text -- ^ Password in plaint-text -> GHandler sub yesod Bool validateUser userID passwd = do@@ -160,12 +171,23 @@ -- | Handle the login form. First parameter is function which maps -- username (whatever it might be) to unique user ID. postLoginR :: ( YesodAuth y, YesodPersist y+ , HashDBUser user, PersistEntity user+#if MIN_VERSION_persistent(1, 1, 0) , b ~ YesodPersistBackend y+ , PersistMonadBackend (b (GHandler Auth y)) ~ PersistEntityBackend user+ , PersistUnique (b (GHandler Auth y))+#else+ , b ~ YesodPersistBackend y , b ~ PersistEntityBackend user- , HashDBUser user, PersistEntity user , PersistStore b (GHandler Auth y)- , PersistUnique b (GHandler Auth y))- => (Text -> Maybe (Unique user b)) + , PersistUnique b (GHandler Auth y)+#endif+ )+#if MIN_VERSION_persistent(1, 1, 0)+ => (Text -> Maybe (Unique user))+#else+ => (Text -> Maybe (Unique user b))+#endif -> GHandler Auth y () postLoginR uniq = do (mu,mp) <- runInputPost $ (,)@@ -185,13 +207,25 @@ -- can be used if authHashDB is the only plugin in use. getAuthIdHashDB :: ( YesodAuth master, YesodPersist master , HashDBUser user, PersistEntity user+#if MIN_VERSION_persistent(1, 1, 0)+ , Key user ~ AuthId master+ , b ~ YesodPersistBackend master+ , PersistMonadBackend (b (GHandler sub master)) ~ PersistEntityBackend user+ , PersistUnique (b (GHandler sub master))+#else , Key b user ~ AuthId master , b ~ YesodPersistBackend master , b ~ PersistEntityBackend user , PersistUnique b (GHandler sub master)- , PersistStore b (GHandler sub master))+ , PersistStore b (GHandler sub master)+#endif+ ) => (AuthRoute -> Route master) -- ^ your site's Auth Route+#if MIN_VERSION_persistent(1, 1, 0)+ -> (Text -> Maybe (Unique user)) -- ^ gets user ID+#else -> (Text -> Maybe (Unique user b)) -- ^ gets user ID+#endif -> Creds master -- ^ the creds argument -> GHandler sub master (Maybe (AuthId master)) getAuthIdHashDB authR uniq creds = do@@ -215,11 +249,18 @@ authHashDB :: ( YesodAuth m, YesodPersist m , HashDBUser user , PersistEntity user+#if MIN_VERSION_persistent(1, 1, 0) , b ~ YesodPersistBackend m+ , PersistMonadBackend (b (GHandler Auth m)) ~ PersistEntityBackend user+ , PersistUnique (b (GHandler Auth m)))+ => (Text -> Maybe (Unique user)) -> AuthPlugin m+#else+ , b ~ YesodPersistBackend m , b ~ PersistEntityBackend user , PersistStore b (GHandler Auth m) , PersistUnique b (GHandler Auth m)) => (Text -> Maybe (Unique user b)) -> AuthPlugin m+#endif authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> toWidget [hamlet| $newline never <div id="header">
yesod-auth.cabal view
@@ -1,5 +1,5 @@ name: yesod-auth-version: 1.1.2+version: 1.1.2.1 license: MIT license-file: LICENSE author: Michael Snoyman, Patrick Brisbin@@ -32,8 +32,8 @@ , unordered-containers , yesod-form >= 1.1 && < 1.3 , transformers >= 0.2.2 && < 0.4- , persistent >= 1.0 && < 1.1- , persistent-template >= 1.0 && < 1.1+ , persistent >= 1.0 && < 1.2+ , persistent-template >= 1.0 && < 1.2 , SHA >= 1.4.1.3 && < 1.7 , http-conduit >= 1.5 && < 1.9 , aeson >= 0.5