diff --git a/Foundation.hs b/Foundation.hs index 83ff501..684f8b8 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -68,6 +68,14 @@ instance Yesod App where master <- getYesod mmsg <- getMessage msu <- lookupSession "userId" + username <- case msu of + Just a -> do + uId <- return $ getUserIdFromText a + user <- runDB $ getJust uId + return $ userName user + otherwise -> do + return ("" :: Text) + -- We break up the default layout into two components: -- default-layout is the contents of the body tag, and diff --git a/Helper.hs b/Helper.hs index 3582be4..73fbe47 100644 --- a/Helper.hs +++ b/Helper.hs @@ -1,7 +1,7 @@ module Helper ( getUserIdFromText , extractKey --- , getUserName +-- , getUserNameById ) where @@ -27,10 +27,9 @@ extractKey = extractKey' . unKey extractKey' (PersistInt64 k) = pack $ show k extractKey' _ = "" ---getUserName :: Text -> User ---getUserName textId = +--getUserNameById :: UserId -> Text +--getUserNameById userId = -- let --- userId = getUserIdFromText textId --- user = get $ userId +-- user = runDB $ getJust $ userId -- in --- show user +-- userName user diff --git a/templates/default-layout.hamlet b/templates/default-layout.hamlet index 2d11200..7f7f940 100644 --- a/templates/default-layout.hamlet +++ b/templates/default-layout.hamlet @@ -2,7 +2,7 @@