From f6ab5c05dc40f51fdae62809d3b54de70b21665a Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 9 Aug 2011 16:48:24 +0300 Subject: [PATCH] Everything building with Hamlet 0.10, scaffolding not fixed yet --- yesod-auth/Yesod/Auth.hs | 14 ++++++++------ yesod-auth/Yesod/Auth/HashDB.hs | 29 +++++++++++++++++------------ yesod-auth/yesod-auth.cabal | 3 ++- yesod-core/Yesod/Message.hs | 2 +- yesod-core/yesod-core.cabal | 7 +++++-- yesod-form/yesod-form.cabal | 4 +++- yesod-json/yesod-json.cabal | 2 +- yesod-newsfeed/yesod-newsfeed.cabal | 2 +- yesod-persistent/Yesod/Persist.hs | 10 +++++++--- yesod-sitemap/yesod-sitemap.cabal | 2 +- yesod/yesod.cabal | 4 +++- 11 files changed, 49 insertions(+), 30 deletions(-) diff --git a/yesod-auth/Yesod/Auth.hs b/yesod-auth/Yesod/Auth.hs index 4b6b5062..abffaa90 100644 --- a/yesod-auth/Yesod/Auth.hs +++ b/yesod-auth/Yesod/Auth.hs @@ -178,11 +178,12 @@ maybeAuthId = do Just s -> return $ fromSinglePiece s maybeAuth :: ( YesodAuth m - , Key val ~ AuthId m - , PersistBackend (YesodDB m (GGHandler s m IO)) + , b ~ YesodPersistBackend m + , Key b val ~ AuthId m + , PersistBackend b (GGHandler s m IO) , PersistEntity val , YesodPersist m - ) => GHandler s m (Maybe (Key val, val)) + ) => GHandler s m (Maybe (Key b val, val)) maybeAuth = runMaybeT $ do aid <- MaybeT $ maybeAuthId a <- MaybeT $ runDB $ get aid @@ -192,11 +193,12 @@ requireAuthId :: YesodAuth m => GHandler s m (AuthId m) requireAuthId = maybeAuthId >>= maybe redirectLogin return requireAuth :: ( YesodAuth m - , Key val ~ AuthId m - , PersistBackend (YesodDB m (GGHandler s m IO)) + , b ~ YesodPersistBackend m + , Key b val ~ AuthId m + , PersistBackend b (GGHandler s m IO) , PersistEntity val , YesodPersist m - ) => GHandler s m (Key val, val) + ) => GHandler s m (Key b val, val) requireAuth = maybeAuth >>= maybe redirectLogin return redirectLogin :: Yesod m => GHandler s m a diff --git a/yesod-auth/Yesod/Auth/HashDB.hs b/yesod-auth/Yesod/Auth/HashDB.hs index acc92243..035526d3 100644 --- a/yesod-auth/Yesod/Auth/HashDB.hs +++ b/yesod-auth/Yesod/Auth/HashDB.hs @@ -65,7 +65,8 @@ module Yesod.Auth.HashDB , authHashDB , getAuthIdHashDB -- * Predefined data type - , User(..) + , User + , UserG (..) , UserId , migrateUsers ) where @@ -127,11 +128,12 @@ setPassword pwd u = do salt <- randomSalt -- | Given a user ID and password in plaintext, validate them against -- the database values. validateUser :: ( YesodPersist yesod - , PersistBackend (YesodDB yesod (GGHandler sub yesod IO)) + , b ~ YesodPersistBackend yesod + , PersistBackend b (GGHandler sub yesod IO) , PersistEntity user , HashDBUser user ) => - Unique user -- ^ User unique identifier + Unique user b -- ^ User unique identifier -> Text -- ^ Password in plaint-text -> GHandler sub yesod Bool validateUser userID passwd = do @@ -151,9 +153,10 @@ login = PluginR "hashdb" ["login"] -- | Handle the login form. First parameter is function which maps -- username (whatever it might be) to unique user ID. postLoginR :: ( YesodAuth y, YesodPersist y + , b ~ YesodPersistBackend y , HashDBUser user, PersistEntity user - , PersistBackend (YesodDB y (GGHandler Auth y IO))) - => (Text -> Maybe (Unique user)) + , PersistBackend b (GGHandler Auth y IO)) + => (Text -> Maybe (Unique user b)) -> GHandler Auth y () postLoginR uniq = do (mu,mp) <- runInputPost $ (,) @@ -173,10 +176,11 @@ postLoginR uniq = do -- can be used if authHashDB is the only plugin in use. getAuthIdHashDB :: ( YesodAuth master, YesodPersist master , HashDBUser user, PersistEntity user - , Key user ~ AuthId master - , PersistBackend (YesodDB master (GGHandler sub master IO))) + , Key b user ~ AuthId master + , b ~ YesodPersistBackend master + , PersistBackend b (GGHandler sub master IO)) => (AuthRoute -> Route master) -- ^ your site's Auth Route - -> (Text -> Maybe (Unique user)) -- ^ gets user ID + -> (Text -> Maybe (Unique user b)) -- ^ gets user ID -> Creds master -- ^ the creds argument -> GHandler sub master (Maybe (AuthId master)) getAuthIdHashDB authR uniq creds = do @@ -200,8 +204,9 @@ getAuthIdHashDB authR uniq creds = do authHashDB :: ( YesodAuth m, YesodPersist m , HashDBUser user , PersistEntity user - , PersistBackend (YesodDB m (GGHandler Auth m IO))) - => (Text -> Maybe (Unique user)) -> AuthPlugin m + , b ~ YesodPersistBackend m + , PersistBackend b (GGHandler Auth m IO)) + => (Text -> Maybe (Unique user b)) -> AuthPlugin m authHashDB uniq = AuthPlugin "hashdb" dispatch $ \tm -> addHamlet [QQ(hamlet)|