yesod / yesod-auth / openid

getRootR :: Handler RepHtml
getRootR = getAfterLoginR
 
getAfterLoginR :: Handler RepHtml
getAfterLoginR = do
    mauth <- maybeAuthId
    defaultLayout $ addHamlet [hamlet|
<p>Auth: #{show mauth}
$maybe _ <- mauth
    <p>
        <a href=@{AuthR LogoutR}>Logout
$nothing
    <p>
        <a href=@{AuthR LoginR}>Login
|]
 
instance Yesod BID where
    approot _ = "http://localhost:3000"
 
instance YesodAuth BID where
    type AuthId BID = Text
    loginDest _ = AfterLoginR
    logoutDest _ = AuthR LoginR
    getAuthId = return . Just . credsIdent
    authPlugins _ = [authOpenId]
    authHttpManager = httpManager
 
instance RenderMessage BID FormMessage where
    renderMessage _ _ = defaultFormMessage
 
main :: IO ()
main = do
    m <- newManager def
    toWaiApp (BID m) >>= run 3000

 

posted @ 2012-03-19 11:32  kelby  阅读(239)  评论(0编辑  收藏  举报