gonito/Handler/Home.hs

35 lines
1.1 KiB
Haskell
Raw Normal View History

2015-08-20 22:33:38 +02:00
module Handler.Home where
import Import
import Handler.Shared
2018-01-18 09:21:21 +01:00
import Handler.ListChallenges
2015-08-20 22:33:38 +02:00
-- This is a handler function for the GET request method on the HomeR
-- resource pattern. All of your resource patterns are defined in
-- config/routes
--
-- The majority of the code you will write in Yesod lives in these handler
-- functions. You can spread them across multiple files if you are so
-- inclined, or create a single monolithic file.
getHomeR :: Handler Html
getHomeR = do
2015-11-11 13:25:09 +01:00
maybeUser <- maybeAuth
master <- getYesod
2018-01-18 09:21:21 +01:00
2018-01-25 16:43:50 +01:00
starredChallenges <- runDB $ selectList [ChallengeStarred ==. True] [Desc ChallengeStamp]
2018-01-18 09:21:21 +01:00
2015-11-11 13:25:09 +01:00
let maybeLocalId = case maybeUser of
Just user -> userLocalId $ entityVal user
Nothing -> Nothing
2017-09-23 15:30:10 +02:00
if maybe False ((\u -> isNothing (userLocalId u) && isNothing (userName u)) . entityVal) maybeUser
then
do
setMessage $ toHtml ("First, set up your name and/or ID!" :: Text)
redirect $ YourAccountR
else
defaultLayout $ do
2015-08-20 22:33:38 +02:00
aDomId <- newIdent
2015-11-11 13:25:09 +01:00
setTitle "Welcome To Gonito.net!"
2015-08-20 22:33:38 +02:00
$(widgetFile "homepage")