apLogin has existential subsite
This commit is contained in:
parent
0fa8280e3d
commit
0cc763d5b8
@ -2,6 +2,7 @@
|
|||||||
{-# LANGUAGE FlexibleContexts #-}
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||||
|
{-# LANGUAGE RankNTypes #-}
|
||||||
module Yesod.Helpers.Auth2
|
module Yesod.Helpers.Auth2
|
||||||
( Auth
|
( Auth
|
||||||
, AuthPlugin (..)
|
, AuthPlugin (..)
|
||||||
@ -30,7 +31,7 @@ type Piece = String
|
|||||||
data AuthPlugin m = AuthPlugin
|
data AuthPlugin m = AuthPlugin
|
||||||
{ apName :: String
|
{ apName :: String
|
||||||
, apDispatch :: Method -> [Piece] -> GHandler Auth m ()
|
, apDispatch :: Method -> [Piece] -> GHandler Auth m ()
|
||||||
, apLogin :: GWidget Auth m ()
|
, apLogin :: forall s. (Route Auth -> Route m) -> GWidget s m ()
|
||||||
}
|
}
|
||||||
|
|
||||||
getAuth :: a -> Auth
|
getAuth :: a -> Auth
|
||||||
@ -117,7 +118,8 @@ $nothing
|
|||||||
getLoginR :: YesodAuth m => GHandler Auth m RepHtml
|
getLoginR :: YesodAuth m => GHandler Auth m RepHtml
|
||||||
getLoginR = defaultLayout $ do
|
getLoginR = defaultLayout $ do
|
||||||
setTitle $ string "Login"
|
setTitle $ string "Login"
|
||||||
mapM_ apLogin authPlugins
|
tm <- liftHandler getRouteToMaster
|
||||||
|
mapM_ (flip apLogin tm) authPlugins
|
||||||
|
|
||||||
getLogoutR :: YesodAuth m => GHandler Auth m ()
|
getLogoutR :: YesodAuth m => GHandler Auth m ()
|
||||||
getLogoutR = postLogoutR -- FIXME redirect to post
|
getLogoutR = postLogoutR -- FIXME redirect to post
|
||||||
@ -189,11 +191,9 @@ authDummy =
|
|||||||
setCreds True $ Creds "dummy" ident []
|
setCreds True $ Creds "dummy" ident []
|
||||||
dispatch _ _ = notFound
|
dispatch _ _ = notFound
|
||||||
url = PluginR "dummy" []
|
url = PluginR "dummy" []
|
||||||
authToMaster = liftHandler getRouteToMaster
|
login authToMaster = do
|
||||||
login = do
|
|
||||||
tm <- authToMaster
|
|
||||||
addBody [$hamlet|
|
addBody [$hamlet|
|
||||||
%form!method=post!action=@tm.url@
|
%form!method=post!action=@authToMaster.url@
|
||||||
Your new identifier is: $
|
Your new identifier is: $
|
||||||
%input!type=text!name=ident
|
%input!type=text!name=ident
|
||||||
%input!type=submit!value="Dummy Login"
|
%input!type=submit!value="Dummy Login"
|
||||||
|
|||||||
@ -76,8 +76,7 @@ authEmail =
|
|||||||
dispatch "POST" ["set-password"] = go postPasswordR
|
dispatch "POST" ["set-password"] = go postPasswordR
|
||||||
dispatch _ _ = notFound
|
dispatch _ _ = notFound
|
||||||
|
|
||||||
login' = do
|
login' tm = do
|
||||||
tm <- liftHandler getRouteToMaster
|
|
||||||
addBody [$hamlet|
|
addBody [$hamlet|
|
||||||
%form!method=post!action=@tm.login@
|
%form!method=post!action=@tm.login@
|
||||||
%table
|
%table
|
||||||
|
|||||||
@ -40,8 +40,7 @@ authFacebook cid secret perms =
|
|||||||
]
|
]
|
||||||
setCreds True c
|
setCreds True c
|
||||||
dispatch _ _ = notFound
|
dispatch _ _ = notFound
|
||||||
login = do
|
login tm = do
|
||||||
tm <- liftHandler getRouteToMaster
|
|
||||||
render <- liftHandler getUrlRender
|
render <- liftHandler 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
|
||||||
|
|||||||
@ -17,8 +17,7 @@ authOpenId =
|
|||||||
complete1 = PluginR "openid" ["complete1"]
|
complete1 = PluginR "openid" ["complete1"]
|
||||||
complete2 = PluginR "openid" ["complete2"]
|
complete2 = PluginR "openid" ["complete2"]
|
||||||
name = "openid_identifier"
|
name = "openid_identifier"
|
||||||
login = do
|
login tm = do
|
||||||
tm <- liftHandler getRouteToMaster
|
|
||||||
addStyle [$cassius|
|
addStyle [$cassius|
|
||||||
#openid
|
#openid
|
||||||
background: #fff url(http://www.myopenid.com/static/openid-icon-small.gif) no-repeat scroll 0pt 50%;
|
background: #fff url(http://www.myopenid.com/static/openid-icon-small.gif) no-repeat scroll 0pt 50%;
|
||||||
|
|||||||
@ -15,8 +15,7 @@ authRpxnow :: YesodAuth m
|
|||||||
authRpxnow app apiKey =
|
authRpxnow app apiKey =
|
||||||
AuthPlugin "rpxnow" dispatch login
|
AuthPlugin "rpxnow" dispatch login
|
||||||
where
|
where
|
||||||
login = do
|
login tm = do
|
||||||
tm <- liftHandler getRouteToMaster
|
|
||||||
let url = {- FIXME urlEncode $ -} tm $ PluginR "rpxnow" []
|
let url = {- FIXME urlEncode $ -} tm $ PluginR "rpxnow" []
|
||||||
addBody [$hamlet|
|
addBody [$hamlet|
|
||||||
%iframe!src="http://$app$.rpxnow.com/openid/embed?token_url=@url@"!scrolling=no!frameBorder=no!allowtransparency=true!style="width:400px;height:240px"
|
%iframe!src="http://$app$.rpxnow.com/openid/embed?token_url=@url@"!scrolling=no!frameBorder=no!allowtransparency=true!style="width:400px;height:240px"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-auth
|
name: yesod-auth
|
||||||
version: 0.0.1
|
version: 0.1.0
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user