Remove liftHandler

This commit is contained in:
Michael Snoyman 2011-01-31 13:26:50 +02:00
parent 66ee5f4c96
commit 71f3170ec8
4 changed files with 14 additions and 10 deletions

View File

@ -37,6 +37,7 @@ import Text.Hamlet (hamlet)
import Data.Text.Lazy (pack) import Data.Text.Lazy (pack)
import Data.JSON.Types (Value (..), Atom (AtomBoolean)) import Data.JSON.Types (Value (..), Atom (AtomBoolean))
import qualified Data.Map as Map import qualified Data.Map as Map
import Control.Monad.Trans.Class (lift)
data Auth = Auth data Auth = Auth
@ -81,7 +82,7 @@ class Yesod m => YesodAuth m where
loginHandler :: GHandler Auth m RepHtml loginHandler :: GHandler Auth m RepHtml
loginHandler = defaultLayout $ do loginHandler = defaultLayout $ do
setTitle $ string "Login" setTitle $ string "Login"
tm <- liftHandler getRouteToMaster tm <- lift getRouteToMaster
mapM_ (flip apLogin tm) authPlugins mapM_ (flip apLogin tm) authPlugins
----- Message strings. In theory in the future make this localizable ----- Message strings. In theory in the future make this localizable

View File

@ -23,6 +23,7 @@ import Yesod.Widget
import Yesod.Core import Yesod.Core
import Text.Hamlet (hamlet) import Text.Hamlet (hamlet)
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Class (lift)
login, register, setpass :: AuthRoute login, register, setpass :: AuthRoute
login = PluginR "email" ["login"] login = PluginR "email" ["login"]
@ -71,7 +72,7 @@ class YesodAuth m => YesodAuthEmail m where
authEmail :: YesodAuthEmail m => AuthPlugin m authEmail :: YesodAuthEmail m => AuthPlugin m
authEmail = authEmail =
AuthPlugin "email" dispatch $ \tm -> do AuthPlugin "email" dispatch $ \tm -> do
y <- liftHandler getYesod y <- lift getYesod
#if GHC7 #if GHC7
[hamlet| [hamlet|
#else #else

View File

@ -15,6 +15,8 @@ import Yesod.Handler
import Yesod.Widget import Yesod.Widget
import Text.Hamlet (hamlet) import Text.Hamlet (hamlet)
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import qualified Data.ByteString.Char8 as S8
import Control.Monad.Trans.Class (lift)
facebookUrl :: AuthRoute facebookUrl :: AuthRoute
facebookUrl = PluginR "facebook" ["forward"] facebookUrl = PluginR "facebook" ["forward"]
@ -32,7 +34,7 @@ authFacebook cid secret perms =
tm <- getRouteToMaster tm <- getRouteToMaster
render <- getUrlRender render <- getUrlRender
let fb = Facebook.Facebook cid secret $ render $ tm url let fb = Facebook.Facebook cid secret $ render $ tm url
redirectString RedirectTemporary $ Facebook.getForwardUrl fb perms redirectString RedirectTemporary $ S8.pack $ Facebook.getForwardUrl fb perms
dispatch "GET" [] = do dispatch "GET" [] = do
render <- getUrlRender render <- getUrlRender
tm <- getRouteToMaster tm <- getRouteToMaster
@ -56,10 +58,10 @@ authFacebook cid secret perms =
setCreds True c setCreds True c
dispatch _ _ = notFound dispatch _ _ = notFound
login tm = do login tm = do
render <- liftHandler getUrlRender render <- lift getUrlRender
let fb = Facebook.Facebook cid secret $ render $ tm url let fb = Facebook.Facebook cid secret $ render $ tm url
let furl = Facebook.getForwardUrl fb $ perms let furl = Facebook.getForwardUrl fb $ perms
y <- liftHandler getYesod y <- lift getYesod
addHtml addHtml
#if GHC7 #if GHC7
[hamlet| [hamlet|

View File

@ -17,6 +17,7 @@ import Text.Hamlet (hamlet)
import Text.Cassius (cassius) import Text.Cassius (cassius)
import Text.Blaze (string) import Text.Blaze (string)
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Class (lift)
import qualified Data.ByteString.Char8 as S8
forwardUrl :: AuthRoute forwardUrl :: AuthRoute
forwardUrl = PluginR "openid" ["forward"] forwardUrl = PluginR "openid" ["forward"]
@ -28,8 +29,8 @@ authOpenId =
complete = PluginR "openid" ["complete"] complete = PluginR "openid" ["complete"]
name = "openid_identifier" name = "openid_identifier"
login tm = do login tm = do
ident <- newIdent ident <- lift newIdent
y <- liftHandler getYesod y <- lift getYesod
addCassius addCassius
#if GHC7 #if GHC7
[cassius|##{ident} [cassius|##{ident}
@ -64,7 +65,7 @@ authOpenId =
setMessage $ string $ show err setMessage $ string $ show err
redirect RedirectTemporary $ toMaster LoginR redirect RedirectTemporary $ toMaster LoginR
) )
(redirectString RedirectTemporary) (redirectString RedirectTemporary . S8.pack)
res res
_ -> do _ -> do
toMaster <- getRouteToMaster toMaster <- getRouteToMaster
@ -74,8 +75,7 @@ authOpenId =
rr <- getRequest rr <- getRequest
completeHelper $ reqGetParams rr completeHelper $ reqGetParams rr
dispatch "POST" ["complete"] = do dispatch "POST" ["complete"] = do
rr <- getRequest (posts, _) <- runRequestBody
(posts, _) <- lift $ reqRequestBody rr
completeHelper posts completeHelper posts
dispatch _ _ = notFound dispatch _ _ = notFound