From 2559346d963ede802321dfc8cbd2088d9a5de685 Mon Sep 17 00:00:00 2001 From: Steffen Date: Wed, 26 Jun 2024 15:08:38 +0200 Subject: [PATCH] fix(avs): new AVS from existing LDAP user no longer misses fields --- src/Handler/Utils/Avs.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Handler/Utils/Avs.hs b/src/Handler/Utils/Avs.hs index e6dbf4943..24ae70bb3 100644 --- a/src/Handler/Utils/Avs.hs +++ b/src/Handler/Utils/Avs.hs @@ -365,9 +365,9 @@ updateAvsUserByADC newAvsDataContact@(AvsDataContact apid newAvsPersonInfo newAv , CU_API_UserMatrikelnummer -- , CU_API_UserCompanyPersonalNumber -- needs special treatment, see ldap_ups above ] - eml_up = mkUpdate usr newAvsDataContact oldAvsDataContact $ mkCheckUpdate CU_ADC_UserDisplayEmail -- Email updates erfolgen nur, wenn identisch. Für Firmen-Email leer lassen. - frm_up = mkUpdate' usr newAvsFirmInfo oldAvsFirmInfo $ mkCheckUpdate CU_AFI_UserPostAddress -- Legacy, if company postal is stored in user; should no longer be true for new users, since company address should now be referenced with UserCompany instead - pin_up = mkUpdate' usr newAvsCardNo oldAvsCardNo $ -- Maybe update PDF pin to latest card + eml_up = mkUpdate usr newAvsDataContact oldAvsDataContact $ mkCheckUpdate CU_ADC_UserDisplayEmail -- Email updates erfolgen nur, wenn identisch. Für Firmen-Email leer lassen. + frm_up = mkUpdate' usr newAvsFirmInfo oldAvsFirmInfo $ mkCheckUpdate CU_AFI_UserPostAddress -- Legacy, if company postal is stored in user; should no longer be true for new users, since company address should now be referenced with UserCompany instead + pin_up = mkUpdate' usr newAvsCardNo oldAvsCardNo $ -- Maybe update PDF pin to latest card CheckUpdate UserPinPassword $ to $ fmap avsFullCardNo2pin -- _Just . to avsFullCardNo2pin . re _Just usr_up1 = eml_up `mcons` (frm_up `mcons` (pin_up `mcons` (ldap_ups <> per_ups))) avs_ups = ((UserAvsNoPerson =.) <$> readMay (avsInfoPersonNo newAvsPersonInfo)) `mcons` @@ -503,15 +503,15 @@ createAvsUserById muid api = do return (mbUid, mbUAvs) usrCardNo <- queryAvsFullCardNo api now <- liftIO getCurrentTime - let usrAvs uid mbFirmInfo = UserAvs + let usrAvs uid mbPersonInfo mbFirmInfo mbUsrCardNo = UserAvs { userAvsPersonId = api , userAvsUser = uid , userAvsNoPerson = fromMaybe (negate $ avsPersonId api) $ readMay $ cpi ^. _avsInfoPersonNo -- negative personId as fallback, but readMay should never fail , userAvsLastSynch = now , userAvsLastSynchError = Nothing - , userAvsLastPersonInfo = Just cpi + , userAvsLastPersonInfo = mbPersonInfo , userAvsLastFirmInfo = mbFirmInfo - , userAvsLastCardNo = usrCardNo + , userAvsLastCardNo = mbUsrCardNo } case oldUsr of (Nothing , Just _) -> throwM $ AvsUserUnknownByAvs api -- this case should never occur @@ -520,7 +520,7 @@ createAvsUserById muid api = do | uid /= uid' -> throwM $ AvsUserAmbiguous api | otherwise -> return uid -- nothing to do (Just uid, Nothing) -> runDB $ do -- link with matching exisitng user - insert_ $ usrAvs uid Nothing -- company info should cause the user to be associated with the company during the update + insert_ $ usrAvs uid Nothing Nothing Nothing -- all infos must be Nothing for subsequent update to work as intended updRes <- updateAvsUserById api -- no loop, since updateAvsUserById does not call createAvsUserById case updRes of Nothing -> throwM $ AvsUserUnknownByAvs api @@ -558,7 +558,7 @@ createAvsUserById muid api = do addCompanySupervisors cid uid repsertSuperiorSupervisor (Just cid) firmInfo uid -- Save AVS data for future updates - insert_ $ usrAvs uid $ Just firmInfo -- unlikely that uid cannot be linked with avsid, but throw if it is not possible + insert_ $ usrAvs uid (Just cpi) (Just firmInfo) usrCardNo -- unlikely that uid cannot be linked with avsid, but throw if it is not possible return uid