diff --git a/Foundation.hs b/Foundation.hs index a48fe76..d9d41bc 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -152,8 +152,10 @@ instance YesodAuth App where , userWalletTimeout = now , userStandingsTimeout = now , userSkillTimeout = now + , userBalanceTimeout = now , userAcc = 0 , userBr = 0 + , userBalanceCents = 0 } Nothing -> return $ ServerError "Problems extracting Access-Token" where diff --git a/Handler/Home.hs b/Handler/Home.hs index 8454e94..797bb9a 100644 --- a/Handler/Home.hs +++ b/Handler/Home.hs @@ -2,39 +2,40 @@ module Handler.Home where import Import --- 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. +loginOrElse :: ((Key User, User) -> Handler Html) -> Handler Html -> Handler Html +loginOrElse cont contElse = do + maid <- maybeAuthId + muid <- case maid of + Just uid -> fmap ((,) uid) <$> runDB (get uid) + Nothing -> return Nothing + case muid of + Nothing -> contElse + Just (uid,u) -> cont (uid,u) + getHomeR :: Handler Html getHomeR = do - maid <- maybeAuthId - muser <- case maid of - Just uid -> runDB $ get uid - Nothing -> return $ Nothing + loginOrElse getLoggedIn getNotLoggedIn + + +getLoggedIn :: (Key User, User) -> Handler Html +getLoggedIn (uid, user) = do + loginLayout user $ [whamlet| +
Current Balance: #{prettyISK $ userBalanceCents user} ISK. +
Current Stock Worth: ... +
Current total Worth: ... +
Profit in the last 7 days: ... + |] + + + +getNotLoggedIn :: Handler Html +getNotLoggedIn = do defaultLayout $ do setTitle "NEAT" [whamlet| -