fix(avs): new AVS from existing LDAP user no longer misses fields
This commit is contained in:
parent
5f1af130ed
commit
2559346d96
@ -365,9 +365,9 @@ updateAvsUserByADC newAvsDataContact@(AvsDataContact apid newAvsPersonInfo newAv
|
|||||||
, CU_API_UserMatrikelnummer
|
, CU_API_UserMatrikelnummer
|
||||||
-- , CU_API_UserCompanyPersonalNumber -- needs special treatment, see ldap_ups above
|
-- , 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.
|
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
|
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
|
pin_up = mkUpdate' usr newAvsCardNo oldAvsCardNo $ -- Maybe update PDF pin to latest card
|
||||||
CheckUpdate UserPinPassword $ to $ fmap avsFullCardNo2pin -- _Just . to avsFullCardNo2pin . re _Just
|
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)))
|
usr_up1 = eml_up `mcons` (frm_up `mcons` (pin_up `mcons` (ldap_ups <> per_ups)))
|
||||||
avs_ups = ((UserAvsNoPerson =.) <$> readMay (avsInfoPersonNo newAvsPersonInfo)) `mcons`
|
avs_ups = ((UserAvsNoPerson =.) <$> readMay (avsInfoPersonNo newAvsPersonInfo)) `mcons`
|
||||||
@ -503,15 +503,15 @@ createAvsUserById muid api = do
|
|||||||
return (mbUid, mbUAvs)
|
return (mbUid, mbUAvs)
|
||||||
usrCardNo <- queryAvsFullCardNo api
|
usrCardNo <- queryAvsFullCardNo api
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
let usrAvs uid mbFirmInfo = UserAvs
|
let usrAvs uid mbPersonInfo mbFirmInfo mbUsrCardNo = UserAvs
|
||||||
{ userAvsPersonId = api
|
{ userAvsPersonId = api
|
||||||
, userAvsUser = uid
|
, userAvsUser = uid
|
||||||
, userAvsNoPerson = fromMaybe (negate $ avsPersonId api) $ readMay $ cpi ^. _avsInfoPersonNo -- negative personId as fallback, but readMay should never fail
|
, userAvsNoPerson = fromMaybe (negate $ avsPersonId api) $ readMay $ cpi ^. _avsInfoPersonNo -- negative personId as fallback, but readMay should never fail
|
||||||
, userAvsLastSynch = now
|
, userAvsLastSynch = now
|
||||||
, userAvsLastSynchError = Nothing
|
, userAvsLastSynchError = Nothing
|
||||||
, userAvsLastPersonInfo = Just cpi
|
, userAvsLastPersonInfo = mbPersonInfo
|
||||||
, userAvsLastFirmInfo = mbFirmInfo
|
, userAvsLastFirmInfo = mbFirmInfo
|
||||||
, userAvsLastCardNo = usrCardNo
|
, userAvsLastCardNo = mbUsrCardNo
|
||||||
}
|
}
|
||||||
case oldUsr of
|
case oldUsr of
|
||||||
(Nothing , Just _) -> throwM $ AvsUserUnknownByAvs api -- this case should never occur
|
(Nothing , Just _) -> throwM $ AvsUserUnknownByAvs api -- this case should never occur
|
||||||
@ -520,7 +520,7 @@ createAvsUserById muid api = do
|
|||||||
| uid /= uid' -> throwM $ AvsUserAmbiguous api
|
| uid /= uid' -> throwM $ AvsUserAmbiguous api
|
||||||
| otherwise -> return uid -- nothing to do
|
| otherwise -> return uid -- nothing to do
|
||||||
(Just uid, Nothing) -> runDB $ do -- link with matching exisitng user
|
(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
|
updRes <- updateAvsUserById api -- no loop, since updateAvsUserById does not call createAvsUserById
|
||||||
case updRes of
|
case updRes of
|
||||||
Nothing -> throwM $ AvsUserUnknownByAvs api
|
Nothing -> throwM $ AvsUserUnknownByAvs api
|
||||||
@ -558,7 +558,7 @@ createAvsUserById muid api = do
|
|||||||
addCompanySupervisors cid uid
|
addCompanySupervisors cid uid
|
||||||
repsertSuperiorSupervisor (Just cid) firmInfo uid
|
repsertSuperiorSupervisor (Just cid) firmInfo uid
|
||||||
-- Save AVS data for future updates
|
-- 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
|
return uid
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user