add login/out

This commit is contained in:
Filip Gralinski 2015-08-29 07:23:34 +02:00
parent 7ff7513fa5
commit f63b296e11
3 changed files with 14 additions and 1 deletions

View File

@ -39,6 +39,8 @@ instance HasHttpManager App where
-- type Widget = WidgetT App IO ()
mkYesodData "App" $(parseRoutesFile "config/routes")
mkMessage "App" "messages" "en"
-- | A convenient synonym for creating forms.
type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)
@ -86,6 +88,8 @@ instance Yesod App where
-- value passed to hamletToRepHtml cannot be a widget, this allows
-- you to use normal widget features in default-layout.
maybeUser <- maybeAuth
pc <- widgetToPageContent $ do
addStylesheet $ StaticR css_bootstrap_css
$(widgetFile "default-layout")

3
messages/en.msg Normal file
View File

@ -0,0 +1,3 @@
LogIn: log in
LogOut: log out
LoggedAs: logged as

View File

@ -1,3 +1,9 @@
<div id="heading">
$maybe user <- maybeUser
_{MsgLoggedAs} #{userIdent $ entityVal user}
\ | <a href="@{AuthR LogoutR}">_{MsgLogOut}</a>
$nothing
<a href="@{AuthR LoginR}">_{MsgLogIn}</a>
$maybe msg <- mmsg
<div #message>#{msg}
<div #message>#{msg}
^{widget}