From e0f631fd0391aed03f5575d43f2b27c68c4501ea Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Sat, 13 May 2023 07:53:14 -0500 Subject: [PATCH] Add obfuscated viewing key --- src/Owner.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Owner.hs b/src/Owner.hs index 630a1fa..029ad4e 100644 --- a/src/Owner.hs +++ b/src/Owner.hs @@ -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