summaryrefslogtreecommitdiff
path: root/src/Identity.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-10-10 21:36:58 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-10-19 21:37:01 +0200
commit5b908c86320ee73f2722c85f8a47fa03ec093c6c (patch)
tree96c57bc839f9c8f50a3bba08075fdfb6ab6eaff4 /src/Identity.hs
parent61808c8cd7b30ceaf9915e72d734c4d095ff67d6 (diff)
Use extended identity data for name
Diffstat (limited to 'src/Identity.hs')
-rw-r--r--src/Identity.hs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/Identity.hs b/src/Identity.hs
index e9216fb..7c49c9f 100644
--- a/src/Identity.hs
+++ b/src/Identity.hs
@@ -220,19 +220,32 @@ createIdentity st name owner = do
(secret, public) <- generateKeys st
(_secretMsg, publicMsg) <- generateKeys st
- let signOwner idd
+ let signOwner :: Signed a -> ReaderT Storage IO (Signed a)
+ signOwner idd
| Just o <- owner = do
Just ownerSecret <- loadKeyMb (iddKeyIdentity $ fromSigned $ idData o)
signAdd ownerSecret idd
| otherwise = return idd
Just identity <- flip runReaderT st $ do
- return . validateIdentity =<< mstore =<< signOwner =<< sign secret =<<
+ baseData <- mstore =<< signOwner =<< sign secret =<<
mstore (emptyIdentityData public)
- { iddName = name
- , iddOwner = idData <$> owner
+ { iddOwner = idData <$> owner
, iddKeyMessage = Just publicMsg
}
+ let extOwner = do
+ odata <- idExtData <$> owner
+ guard $ isExtension odata
+ return odata
+
+ validateExtendedIdentityF . I.Identity <$>
+ if isJust name || isJust extOwner
+ then mstore =<< signOwner =<< sign secret =<<
+ mstore . ExtendedIdentityData =<< return (emptyIdentityExtension baseData)
+ { ideName = name
+ , ideOwner = extOwner
+ }
+ else return $ baseToExtended baseData
return identity
validateIdentity :: Stored (Signed IdentityData) -> Maybe UnifiedIdentity