changed handler

This commit is contained in:
Nicole Dresselhaus 2015-04-27 17:31:06 +02:00
parent 7b18752be2
commit 96e63b0299
2 changed files with 28 additions and 15 deletions

View File

@ -135,7 +135,8 @@ instance YesodAuth App where
} }
-- You can add other plugins like BrowserID, email or OAuth here -- You can add other plugins like BrowserID, email or OAuth here
authPlugins _ = [authBrowserId def] authPlugins _ = [ authBrowserId def
]
authHttpManager = getHttpManager authHttpManager = getHttpManager

View File

@ -14,6 +14,7 @@ import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
-- inclined, or create a single monolithic file. -- inclined, or create a single monolithic file.
getHomeR :: Handler Html getHomeR :: Handler Html
getHomeR = do getHomeR = do
maid <- maybeAuthId
(loginWidget, loginEnctype) <- generateFormPost loginForm (loginWidget, loginEnctype) <- generateFormPost loginForm
defaultLayout $ do defaultLayout $ do
setTitle "NEAT" setTitle "NEAT"
@ -21,11 +22,18 @@ getHomeR = do
<h1> <h1>
Welcome to NEAT. Welcome to NEAT.
<div> <div>
Login Current Auth-ID: #{show maid}.
<form method=post action=@{HomeR} enctype=#{loginEnctype}> $maybe u <- maid
^{loginWidget} <p>
<button>Submit Data: #{show u}<br>
<a href=@{RegisterR}>Register Account <a href=@{AuthR LogoutR}>Logout
$nothing
Login
<a href=@{AuthR LoginR}>Login-Page
<form method=post action=@{HomeR} enctype=#{loginEnctype}>
^{loginWidget}
<button>Submit
<a href=@{RegisterR}>Register Account
|] |]
{- {-
(formWidget, formEnctype) <- generateFormPost sampleForm (formWidget, formEnctype) <- generateFormPost sampleForm
@ -38,16 +46,20 @@ getHomeR = do
postHomeR :: Handler Html postHomeR :: Handler Html
postHomeR = do postHomeR = do
((result, formWidget), formEnctype) <- runFormPost sampleForm ((result, loginWidget), loginEnctype) <- runFormPost loginForm
let handlerName = "postHomeR" :: Text
submission = case result of
FormSuccess res -> Just res
_ -> Nothing
defaultLayout $ do defaultLayout $ do
aDomId <- newIdent setTitle "NEAT"
setTitle "Welcome To Yesod!" [whamlet|
$(widgetFile "homepage") <h1>
Welcome to NEAT.
<div>
Login
<form method=post action=@{HomeR} enctype=#{loginEnctype}>
^{loginWidget}
<button>Submit
<a href=@{RegisterR}>Register Account
|]
sampleForm :: Form (FileInfo, Text) sampleForm :: Form (FileInfo, Text)
sampleForm = renderBootstrap3 BootstrapBasicForm $ (,) sampleForm = renderBootstrap3 BootstrapBasicForm $ (,)