fix(avs): new AVS from existing LDAP user no longer misses fields
This commit is contained in:
parent
5f1af130ed
commit
2559346d96
@ -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