about summary refs log tree commit diff
path: root/src/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Types.hs')
-rw-r--r--src/Types.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Types.hs b/src/Types.hs
index 3a410dc4b525..c2f0ee19b4d7 100644
--- a/src/Types.hs
+++ b/src/Types.hs
@@ -33,3 +33,36 @@ instance ToJSON User where
     object [ "name" .= name
            , "age"  .= age
            ]
+
+newtype Username = Username Text
+  deriving (Eq, Show)
+
+instance ToJSON Username where
+  toJSON (Username x) = toJSON x
+
+newtype Password = Password Text
+  deriving (Eq, Show)
+
+instance ToJSON Password where
+  toJSON (Password x) = toJSON x
+
+data Role = RegularUser | Manager | Admin
+  deriving (Eq, Show)
+
+instance ToJSON Role where
+  toJSON RegularUser = "user"
+  toJSON Manager = "manager"
+  toJSON Admin = "admin"
+
+data Session = Session
+  { username :: Username
+  , password :: Password
+  , role :: Role
+  } deriving (Eq, Show)
+
+instance ToJSON Session where
+  toJSON (Session username password role) =
+    object [ "username" .= username
+           , "password" .= password
+           , "role" .= role
+           ]