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
1 changed files with 7 additions and 2 deletions

View File

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