shit doesn't work
This commit is contained in:
parent
87611667a7
commit
a992307327
4 changed files with 21 additions and 2 deletions
|
@ -21,6 +21,7 @@ import Yesod.Core.Types (Logger)
|
||||||
-- costom imports
|
-- costom imports
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Text
|
import Data.Text
|
||||||
|
import Helper
|
||||||
|
|
||||||
-- | The site argument for your application. This can be a good place to
|
-- | The site argument for your application. This can be a good place to
|
||||||
-- keep settings and values requiring initialization before your application
|
-- keep settings and values requiring initialization before your application
|
||||||
|
|
|
@ -37,3 +37,4 @@ albumForm userId = renderDivs $ Album
|
||||||
<$> areq textField "Title" Nothing
|
<$> areq textField "Title" Nothing
|
||||||
<*> pure userId
|
<*> pure userId
|
||||||
<*> pure []
|
<*> pure []
|
||||||
|
<*> pure Nothing
|
||||||
|
|
19
Helper.hs
19
Helper.hs
|
@ -1,14 +1,23 @@
|
||||||
module Helper
|
module Helper
|
||||||
( getUserIdFromText
|
( getUserIdFromText
|
||||||
, extractKey
|
, extractKey
|
||||||
|
-- , getUserName
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
import Model
|
||||||
|
import Control.Applicative
|
||||||
|
import Control.Monad.Trans.Class
|
||||||
import Data.Text
|
import Data.Text
|
||||||
|
import Data.Maybe
|
||||||
|
import Database.Persist
|
||||||
import Database.Persist.Types
|
import Database.Persist.Types
|
||||||
|
import System.FilePath
|
||||||
|
import Yesod.Persist.Core
|
||||||
|
import Yesod.Core.Types
|
||||||
|
|
||||||
getUserIdFromText :: Text -> PersistValue
|
getUserIdFromText :: Text -> UserId
|
||||||
getUserIdFromText tempUserId =
|
getUserIdFromText tempUserId =
|
||||||
PersistInt64 $ fromIntegral $ read $ unpack tempUserId
|
PersistInt64 $ fromIntegral $ read $ unpack tempUserId
|
||||||
|
|
||||||
|
@ -17,3 +26,11 @@ extractKey = extractKey' . unKey
|
||||||
where
|
where
|
||||||
extractKey' (PersistInt64 k) = pack $ show k
|
extractKey' (PersistInt64 k) = pack $ show k
|
||||||
extractKey' _ = ""
|
extractKey' _ = ""
|
||||||
|
|
||||||
|
--getUserName :: Text -> User
|
||||||
|
--getUserName textId =
|
||||||
|
-- let
|
||||||
|
-- userId = getUserIdFromText textId
|
||||||
|
-- user = get $ userId
|
||||||
|
-- in
|
||||||
|
-- show user
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div id="top-nav">
|
<div id="top-nav">
|
||||||
<ul id="user-nav">
|
<ul id="user-nav">
|
||||||
$maybe userId <- msu
|
$maybe userId <- msu
|
||||||
Logged in as #{userId}
|
Logged in as <a href=@{ProfileR $ getUserIdFromText userId}>$user
|
||||||
<li>
|
<li>
|
||||||
<a href=@{LogoutR}>Logout
|
<a href=@{LogoutR}>Logout
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Reference in a new issue