Distinguish b/w Account and User
Additionally: supporting more CRUDL methods for the Accounts and Trips tables.
This commit is contained in:
parent
6d9e76313d
commit
2398f1bd40
3 changed files with 63 additions and 26 deletions
19
src/Types.hs
19
src/Types.hs
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue