Prefer name ClearTextPassword to Password

I expect my application to have two types for passwords:
- ClearTextPassword
- CipherTextPassword
This commit is contained in:
William Carroll 2020-07-28 11:19:05 +01:00
parent 2398f1bd40
commit 502126243d

View file

@ -43,17 +43,17 @@ instance ToField Username where
instance FromField Username where instance FromField Username where
fromField = forNewtype Username fromField = forNewtype Username
newtype Password = Password Text newtype ClearTextPassword = ClearTextPassword Text
deriving (Eq, Show, Generic) deriving (Eq, Show, Generic)
instance ToJSON Password instance ToJSON ClearTextPassword
instance FromJSON Password instance FromJSON ClearTextPassword
instance ToField Password where instance ToField ClearTextPassword where
toField (Password x) = SQLText x toField (ClearTextPassword x) = SQLText x
instance FromField Password where instance FromField ClearTextPassword where
fromField = forNewtype Password fromField = forNewtype ClearTextPassword
newtype Email = Email Text newtype Email = Email Text
deriving (Eq, Show, Generic) deriving (Eq, Show, Generic)
@ -101,7 +101,7 @@ instance FromField ProfilePicture where
data Account = Account data Account = Account
{ accountUsername :: Username { accountUsername :: Username
, accountPassword :: Password , accountPassword :: ClearTextPassword
, accountEmail :: Email , accountEmail :: Email
, accountRole :: Role , accountRole :: Role
, accountProfilePicture :: ProfilePicture , accountProfilePicture :: ProfilePicture
@ -112,7 +112,7 @@ instance ToJSON Account
instance FromJSON Account instance FromJSON Account
-- | Return a tuple with all of the fields for an Account record to use for SQL. -- | 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 accountFields (Account { accountUsername
, accountPassword , accountPassword
, accountEmail , accountEmail
@ -135,7 +135,7 @@ instance FromRow Account where
data Session = Session data Session = Session
{ username :: Username { username :: Username
, password :: Password , password :: ClearTextPassword
, role :: Role , role :: Role
} deriving (Eq, Show) } deriving (Eq, Show)