diff options
author | Joris | 2015-09-05 13:53:36 +0200 |
---|---|---|
committer | Joris | 2015-09-05 13:53:36 +0200 |
commit | 3b738e0d4cc65f314da7389d4542ec826ba0f454 (patch) | |
tree | ee99236117ad698974c5a6e40ab170f617cb06f3 /src/server/Model/User.hs | |
parent | 139d4a103a6a48880e5f12a796033956f223563c (diff) |
Using UserId instead of UserName to indentify users
Diffstat (limited to 'src/server/Model/User.hs')
-rw-r--r-- | src/server/Model/User.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/server/Model/User.hs b/src/server/Model/User.hs index 339aff6..2b52d03 100644 --- a/src/server/Model/User.hs +++ b/src/server/Model/User.hs @@ -1,6 +1,7 @@ module Model.User ( getUsers , getUser + , getJsonUser , createUser , deleteUser ) where @@ -13,13 +14,19 @@ import Control.Monad.IO.Class (liftIO) import Database.Persist import Model.Database +import qualified Model.Json.User as Json -getUsers :: Persist [User] -getUsers = map entityVal <$> selectList [] [Desc UserCreation] +getUsers :: Persist [Entity User] +getUsers = selectList [] [Desc UserCreation] getUser :: Text -> Persist (Maybe (Entity User)) getUser email = selectFirst [UserEmail ==. email] [] +getJsonUser :: Entity User -> Json.User +getJsonUser userEntity = + let user = entityVal userEntity + in Json.User (entityKey userEntity) (userName user) (userEmail user) + createUser :: Text -> Text -> Persist UserId createUser email name = do now <- liftIO getCurrentTime |