Distinguish b/w Account and User

Additionally: supporting more CRUDL methods for the Accounts and Trips tables.
This commit is contained in:
William Carroll 2020-07-28 10:57:15 +01:00
parent 6d9e76313d
commit 2398f1bd40
3 changed files with 63 additions and 26 deletions

View file

@ -234,3 +234,22 @@ tripFields (Trip{ tripUsername
instance ToJSON Trip
instance FromJSON Trip
-- | Users and Accounts both refer to the same underlying entities; however,
-- Users model the user-facing Account details, hiding sensitive details like
-- passwords and emails.
data User = User
{ userUsername :: Username
, userProfilePicture :: ProfilePicture
, userRole :: Role
} deriving (Eq, Show, Generic)
instance ToJSON User
instance FromJSON User
userFromAccount :: Account -> User
userFromAccount account =
User { userUsername = accountUsername account
, userProfilePicture = accountProfilePicture account
, userRole = accountRole account
}