fix(ldap): match mobile number better between LDAP and AVS

This commit is contained in:
Steffen Jost 2024-06-26 14:07:52 +02:00
parent f108c6cfec
commit 47e56280fc
2 changed files with 8 additions and 3 deletions

View File

@ -182,7 +182,6 @@ upsertCampusUser upsertMode ldapData = do
userDefaultConf <- getsYesod $ view _appUserDefaults
(newUser,userUpdate) <- decodeUser now userDefaultConf upsertMode ldapData
--TODO: newUser should be associated with a company and company supervisor through Handler.Utils.Company.oldUpsertUserCompany, but this is called by upsertAvsUser already - conflict?
oldUsers <- for (userLdapPrimaryKey newUser) $ \pKey -> selectKeysList [ UserLdapPrimaryKey ==. Just pKey ] []
@ -230,8 +229,8 @@ decodeUserTest mbIdent ldapData = do
decodeUser :: (MonadThrow m) => UTCTime -> UserDefaultConf -> UpsertCampusUserMode -> Ldap.AttrList [] -> m (User,_)
decodeUser now UserDefaultConf{..} upsertMode ldapData = do
let
userTelephone = decodeLdap ldapUserTelephone
userMobile = decodeLdap ldapUserMobile
userTelephone = decodeLdap ldapUserTelephone <&> canonicalPhone
userMobile = decodeLdap ldapUserMobile <&> canonicalPhone
userCompanyPersonalNumber = decodeLdap ldapUserFraportPersonalnummer
userCompanyDepartment = decodeLdap ldapUserFraportAbteilung

View File

@ -84,7 +84,13 @@ canonicalPhone pn
| otherwise
= Text.map repl_nondigit pn
where
-- split_area :: Text -> Char -> Int -> Text -> Text
-- split_area c f p n =
-- let (area,sufx) = Text.splitAt p $ Text.filter Char.isDigit n
-- in c <> Text.cons f area <> Text.cons ' ' sufx
german_mobile :: Text -> Text
--german_mobile = split_area "+49" '1' 2
german_mobile wpx =
let (area,endnr) = Text.splitAt 2 $ Text.filter Char.isDigit wpx
in "+49 1" <> area <> Text.cons ' ' endnr