From 502126243d221fc56345ccd7e4b72882f2128953 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Tue, 28 Jul 2020 11:19:05 +0100 Subject: [PATCH] Prefer name ClearTextPassword to Password I expect my application to have two types for passwords: - ClearTextPassword - CipherTextPassword --- src/Types.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Types.hs b/src/Types.hs index 2f78ddb9a..bd4544deb 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -43,17 +43,17 @@ instance ToField Username where instance FromField Username where fromField = forNewtype Username -newtype Password = Password Text +newtype ClearTextPassword = ClearTextPassword Text deriving (Eq, Show, Generic) -instance ToJSON Password -instance FromJSON Password +instance ToJSON ClearTextPassword +instance FromJSON ClearTextPassword -instance ToField Password where - toField (Password x) = SQLText x +instance ToField ClearTextPassword where + toField (ClearTextPassword x) = SQLText x -instance FromField Password where - fromField = forNewtype Password +instance FromField ClearTextPassword where + fromField = forNewtype ClearTextPassword newtype Email = Email Text deriving (Eq, Show, Generic) @@ -101,7 +101,7 @@ instance FromField ProfilePicture where data Account = Account { accountUsername :: Username - , accountPassword :: Password + , accountPassword :: ClearTextPassword , accountEmail :: Email , accountRole :: Role , accountProfilePicture :: ProfilePicture @@ -112,7 +112,7 @@ instance ToJSON Account instance FromJSON Account -- | Return a tuple with all of the fields for an Account record to use for SQL. -accountFields :: Account -> (Username, Password, Email, Role, ProfilePicture) +accountFields :: Account -> (Username, ClearTextPassword, Email, Role, ProfilePicture) accountFields (Account { accountUsername , accountPassword , accountEmail @@ -135,7 +135,7 @@ instance FromRow Account where data Session = Session { username :: Username - , password :: Password + , password :: ClearTextPassword , role :: Role } deriving (Eq, Show)