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
|]
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|]
siteLayout locallyDefinedPageHeading $ do
-- defaultLayout $ do
setTitle "Uni2work Admin Testpage"
setTitle "Uni2work Admin Testpage"
$(i18nWidgetFile "admin-test")
[whamlet|
<h2>User CryptoId and CryptoFileName
<dl>
<dt>CryptoUUIDUser
<dd>#{usrCryptoUUID}
<dt>CryptoFileNameUser
<dd>#{usrCryptoFileName}
|]
[whamlet|<h2>Formular Demonstration|]
wrapForm formWidget FormSettings
{ formMethod = POST

View File

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

View File

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

View File

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