diff options
author | William Carroll <wpcarro@gmail.com> | 2020-07-28T09·57+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-07-28T09·57+0100 |
commit | 2398f1bd40235ce4ff031dccbde4d04b32395292 (patch) | |
tree | 68a43d3ee98f7eb3815b7f79af6d789eb60fe1c3 /src/Types.hs | |
parent | 6d9e76313d1f89dcf4c1adb7bfabd811a65bd83a (diff) |
Distinguish b/w Account and User
Additionally: supporting more CRUDL methods for the Accounts and Trips tables.
Diffstat (limited to 'src/Types.hs')
-rw-r--r-- | src/Types.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Types.hs b/src/Types.hs index 6d6b83347931..2f78ddb9a112 100644 --- a/src/Types.hs +++ b/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 + } |