Add obfuscated viewing key

This commit is contained in:
Rene Vergara 2023-05-13 07:53:14 -05:00
parent 24d8f25ed1
commit e0f631fd03
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2

View file

@ -324,6 +324,7 @@ data OwnerSettings =
, os_expiration :: UTCTime , os_expiration :: UTCTime
, os_payconf :: Bool , os_payconf :: Bool
, os_crmToken :: T.Text , os_crmToken :: T.Text
, os_viewKey :: T.Text
} }
deriving (Eq, Show, Generic) deriving (Eq, Show, Generic)
@ -344,10 +345,12 @@ instance FromJSON OwnerSettings where
e <- obj .: "expiration" e <- obj .: "expiration"
pc <- obj .: "payconf" pc <- obj .: "payconf"
cT <- obj .: "crmToken" cT <- obj .: "crmToken"
pure $ OwnerSettings ((Just . read) =<< i) a n c t tV v vV p z inv e pc cT vK <- obj .: "viewkey"
pure $
OwnerSettings ((Just . read) =<< i) a n c t tV v vV p z inv e pc cT vK
instance ToJSON OwnerSettings where instance ToJSON OwnerSettings where
toJSON (OwnerSettings i a n c t tV v vV p z inv e pc cT) = toJSON (OwnerSettings i a n c t tV v vV p z inv e pc cT vK) =
object object
[ "_id" .= maybe "" show i [ "_id" .= maybe "" show i
, "address" .= a , "address" .= a
@ -363,6 +366,7 @@ instance ToJSON OwnerSettings where
, "expiration" .= e , "expiration" .= e
, "payconf" .= pc , "payconf" .= pc
, "crmToken" .= cT , "crmToken" .= cT
, "viewkey" .= (T.take 5 vK <> "...." <> T.takeEnd 5 vK)
] ]
-- Helper Functions -- Helper Functions
@ -383,6 +387,7 @@ getOwnerSettings o =
(oexpiration o) (oexpiration o)
(opayconf o) (opayconf o)
(ocrmToken o) (ocrmToken o)
(oviewkey o)
-- Database actions -- Database actions
-- | Function to upsert an Owner -- | Function to upsert an Owner