chore(lpr): quick fix short apc ids expiry

This commit is contained in:
Steffen Jost 2023-05-22 16:40:56 +00:00
parent 132a0438ef
commit 807cf4b3cf
5 changed files with 25 additions and 6 deletions

View File

@ -215,12 +215,29 @@ postAdminTestR = do
Button-Modal Button-Modal
|] |]
mkCryptoFilnameUser :: UserId -> Handler CryptoFileNameUser
mkCryptoFilnameUser = encrypt
mkCryptoUUIDUser :: UserId -> Handler CryptoUUIDUser
mkCryptoUUIDUser = encrypt
usrCryptoFileName <- maybeM (return "no-user_id") (fmap toPathPiece . mkCryptoFilnameUser) maybeAuthId
usrCryptoUUID <- maybeM (return "no-user_id") (fmap toPathPiece . mkCryptoUUIDUser) maybeAuthId
let locallyDefinedPageHeading = [whamlet|Admin TestPage for Uni2work|] let locallyDefinedPageHeading = [whamlet|Admin TestPage for Uni2work|]
siteLayout locallyDefinedPageHeading $ do siteLayout locallyDefinedPageHeading $ do
-- defaultLayout $ do -- defaultLayout $ do
setTitle "Uni2work Admin Testpage" setTitle "Uni2work Admin Testpage"
$(i18nWidgetFile "admin-test") $(i18nWidgetFile "admin-test")
[whamlet|
<h2>User CryptoId and CryptoFileName
<dl>
<dt>CryptoUUIDUser
<dd>#{usrCryptoUUID}
<dt>CryptoFileNameUser
<dd>#{usrCryptoFileName}
|]
[whamlet|<h2>Formular Demonstration|] [whamlet|<h2>Formular Demonstration|]
wrapForm formWidget FormSettings wrapForm formWidget FormSettings
{ formMethod = POST { formMethod = POST

View File

@ -91,10 +91,11 @@ lrqf2letter LRQF{..}
| lrqfLetter == "e" || lrqfLetter == "E" = do | lrqfLetter == "e" || lrqfLetter == "E" = do
rcvr <- mapM getUser lrqfSuper rcvr <- mapM getUser lrqfSuper
usr <- getUser lrqfUser usr <- getUser lrqfUser
usrShrt <- encrypt $ entityKey usr
usrUuid <- encrypt $ entityKey usr usrUuid <- encrypt $ entityKey usr
urender <- liftHandler getUrlRender urender <- liftHandler getUrlRender
let letter = LetterExpireQualificationF let letter = LetterExpireQualificationF
{ leqfHolderUUID = usrUuid { leqfHolderCFN = usrShrt
, leqfHolderID = usr ^. _entityKey , leqfHolderID = usr ^. _entityKey
, leqfHolderDN = usr ^. _userDisplayName , leqfHolderDN = usr ^. _userDisplayName
, leqfHolderSN = usr ^. _userSurname , leqfHolderSN = usr ^. _userSurname

View File

@ -45,6 +45,7 @@ dispatchNotificationQualificationExpiry nQualification dExpiry jRecipient = user
dispatchNotificationQualificationExpired :: QualificationId -> UserId -> Handler () dispatchNotificationQualificationExpired :: QualificationId -> UserId -> Handler ()
dispatchNotificationQualificationExpired nQualification jRecipient = do dispatchNotificationQualificationExpired nQualification jRecipient = do
encRecipient :: CryptoUUIDUser <- encrypt jRecipient encRecipient :: CryptoUUIDUser <- encrypt jRecipient
encRecShort <- encrypt jRecipient
dbRes <- runDB $ (,,) dbRes <- runDB $ (,,)
<$> get jRecipient <$> get jRecipient
<*> get nQualification <*> get nQualification
@ -57,7 +58,7 @@ dispatchNotificationQualificationExpired nQualification jRecipient = do
qname = CI.original qualificationName qname = CI.original qualificationName
qshort = CI.original qualificationShorthand qshort = CI.original qualificationShorthand
letter = LetterExpireQualificationF letter = LetterExpireQualificationF
{ leqfHolderUUID = encRecipient { leqfHolderCFN = encRecShort
, leqfHolderID = jRecipient , leqfHolderID = jRecipient
, leqfHolderDN = userDisplayName , leqfHolderDN = userDisplayName
, leqfHolderSN = userSurname , leqfHolderSN = userSurname

View File

@ -20,7 +20,7 @@ import Handler.Utils.Widgets (nameHtml) -- , nameHtml')
data LetterExpireQualificationF = LetterExpireQualificationF data LetterExpireQualificationF = LetterExpireQualificationF
{ leqfHolderUUID:: CryptoUUIDUser { leqfHolderCFN :: CryptoFileNameUser
, leqfHolderID :: UserId , leqfHolderID :: UserId
, leqfHolderDN :: UserDisplayName , leqfHolderDN :: UserDisplayName
, leqfHolderSN :: UserSurname , leqfHolderSN :: UserSurname
@ -78,7 +78,7 @@ instance MDLetter LetterExpireQualificationF where
getPJId LetterExpireQualificationF{..} = getPJId LetterExpireQualificationF{..} =
PrintJobIdentification PrintJobIdentification
{ pjiName = "Expiry" { pjiName = "Expiry"
, pjiApcAcknowledge = "exp-" <> tshow (ciphertext leqfHolderUUID) , pjiApcAcknowledge = "ex-" <> toPathPiece leqfHolderCFN
, pjiRecipient = Nothing -- to be filled later , pjiRecipient = Nothing -- to be filled later
, pjiSender = Nothing , pjiSender = Nothing
, pjiCourse = Nothing , pjiCourse = Nothing

View File

@ -182,7 +182,7 @@ mkApcIdent uuid envelope lk tnow apcAck = Text.filter apcAcceptedChars $ Text.in
[ ensureLength 38 $ tshow (ciphertext uuid) <> Text.cons '-' (Text.singleton envelope) [ ensureLength 38 $ tshow (ciphertext uuid) <> Text.cons '-' (Text.singleton envelope)
, ensureLength 5 $ paperKind lk , ensureLength 5 $ paperKind lk
, ensureLength 9 tnow , ensureLength 9 tnow
, apcAck -- length of last part may be arbitrary, thus far was always 12 , Text.take 32 apcAck -- length of last part may be arbitrary, but more than 32 symbols do not fit into the line
] ]
where where
ensureLength :: Int -> Text -> Text ensureLength :: Int -> Text -> Text