From 8a08357c3d9f59f0b9019958e641e143042ad6a2 Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Mon, 5 Dec 2022 16:55:15 +0100 Subject: [PATCH 1/2] chore(release): 26.6.5 --- CHANGELOG.md | 2 ++ nix/docker/demo-version.json | 2 +- nix/docker/version.json | 2 +- package-lock.json | 2 +- package.json | 2 +- package.yaml | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6277d4e0..ac54a44f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [26.6.5](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/v26.6.4...v26.6.5) (2022-12-05) + ## [26.6.4](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/v26.6.3...v26.6.4) (2022-12-02) ## [26.6.3](https://gitlab2.rz.ifi.lmu.de/uni2work/uni2work/compare/v26.6.2...v26.6.3) (2022-11-30) diff --git a/nix/docker/demo-version.json b/nix/docker/demo-version.json index 863c6fce8..f42a7f000 100644 --- a/nix/docker/demo-version.json +++ b/nix/docker/demo-version.json @@ -1,3 +1,3 @@ { - "version": "26.6.4" + "version": "26.6.5" } diff --git a/nix/docker/version.json b/nix/docker/version.json index 863c6fce8..f42a7f000 100644 --- a/nix/docker/version.json +++ b/nix/docker/version.json @@ -1,3 +1,3 @@ { - "version": "26.6.4" + "version": "26.6.5" } diff --git a/package-lock.json b/package-lock.json index 9f352bc2d..05f9e6c8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "uni2work", - "version": "26.6.4", + "version": "26.6.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8ad468f71..4bf51a611 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uni2work", - "version": "26.6.4", + "version": "26.6.5", "description": "", "keywords": [], "author": "", diff --git a/package.yaml b/package.yaml index acd9e9c09..df5990b79 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: uniworx -version: 26.6.4 +version: 26.6.5 dependencies: - base - yesod From 47073d10f419ac10cd2849824c6c69202ef9c82f Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Tue, 6 Dec 2022 14:49:50 +0100 Subject: [PATCH 2/2] chore(avs): store and show avs person number, fixes #10 --- messages/uniworx/categories/avs/de-de-formal.msg | 3 ++- messages/uniworx/categories/avs/en-eu.msg | 3 ++- models/avs.model | 3 ++- src/Handler/Profile.hs | 5 ++++- src/Handler/Utils/Avs.hs | 11 ++++++----- src/Utils.hs | 10 ++++++++++ src/Utils/Lens.hs | 2 ++ templates/profileData.hamlet | 10 ++++++++-- test/Database/Fill.hs | 1 + 9 files changed, 37 insertions(+), 11 deletions(-) diff --git a/messages/uniworx/categories/avs/de-de-formal.msg b/messages/uniworx/categories/avs/de-de-formal.msg index 45e3c9131..169fd2987 100644 --- a/messages/uniworx/categories/avs/de-de-formal.msg +++ b/messages/uniworx/categories/avs/de-de-formal.msg @@ -11,4 +11,5 @@ AvsInternalPersonalNo: Personalnummer (nur Fraport AG) AvsVersionNo: Versionsnummer AvsQueryEmpty: Bitte mindestens ein Anfragefeld ausfüllen! AvsQueryStatusInvalid t@Text: Nur numerische IDs eingeben, durch Komma getrennt! Erhalten: #{show t} -AvsLicence: Fahrberechtigung \ No newline at end of file +AvsLicence: Fahrberechtigung +AvsPersonNoNotId: AVS Personennummer dient zur menschlichen Kommunikation mit der Ausweisstelle und darf nicht verwechselt werden mit der maschinell verwendeten AVS Personen Id \ No newline at end of file diff --git a/messages/uniworx/categories/avs/en-eu.msg b/messages/uniworx/categories/avs/en-eu.msg index 7660963b6..3ee9a293e 100644 --- a/messages/uniworx/categories/avs/en-eu.msg +++ b/messages/uniworx/categories/avs/en-eu.msg @@ -11,4 +11,5 @@ AvsInternalPersonalNo: Personnel number (Fraport AG only) AvsVersionNo: Version number AvsQueryEmpty: At least one query field must be filled! AvsQueryStatusInvalid t: Numeric IDs only, comma seperated! #{show t} -AvsLicence: Driving Licence \ No newline at end of file +AvsLicence: Driving Licence +AvsPersonNoNotId: AVS person number is used in human communication only and must not be mistaken for the AVS personen id used in machine communications \ No newline at end of file diff --git a/models/avs.model b/models/avs.model index 041c6aba0..5bb75e315 100644 --- a/models/avs.model +++ b/models/avs.model @@ -14,8 +14,9 @@ UserAvs - personId AvsPersonId -- unique identifier for user throughout avs; newtype for Int + personId AvsPersonId -- unique identifier for user throughout avs; newtype for Int user UserId + noPerson Int default=0 -- only needed for manual communication with personnel from Ausweisverwaltungsstelle UniqueUserAvsUser user UniqueUserAvsId personId deriving Generic diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index a7e60b53c..c4ab032bb 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -653,6 +653,8 @@ getForProfileDataR cID = do makeProfileData :: Entity User -> DB Widget makeProfileData (Entity uid User{..}) = do + avsId <- entityVal <<$>> getBy (UniqueUserAvsUser uid) + -- avsCards <- maybe (pure mempty) (\a -> selectList [UserAvsCardPersonId ==. userAvsPersonId a] []) avsId functions <- Map.fromListWith Set.union . map (\(Entity _ UserFunction{..}) -> (userFunctionFunction, Set.singleton userFunctionSchool)) <$> selectList [UserFunctionUser ==. uid] [] lecture_corrector <- E.select $ E.distinct $ E.from $ \(sheet `E.InnerJoin` corrector `E.InnerJoin` course) -> do E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId @@ -699,7 +701,8 @@ makeProfileData (Entity uid User{..}) = do cID <- encrypt uid mCRoute <- getCurrentRoute - showAdminInfo <- pure (mCRoute == Just (AdminUserR cID)) `or2M` hasReadAccessTo (AdminUserR cID) + showAdminInfo <- pure (mCRoute == Just (AdminUserR cID)) `or2M` hasReadAccessTo (AdminUserR cID) + tooltipAvsPersNo <- messageI Info MsgAvsPersonNoNotId let profileRemarks = $(i18nWidgetFile "profile-remarks") return $(widgetFile "profileData") diff --git a/src/Handler/Utils/Avs.hs b/src/Handler/Utils/Avs.hs index d97f2e8e5..103bf920c 100644 --- a/src/Handler/Utils/Avs.hs +++ b/src/Handler/Utils/Avs.hs @@ -272,14 +272,14 @@ upsertAvsUserById api = do $logInfoS "AVS" $ "Creating new user with avsInternalPersonalNo " <> tshow persNo candidates <- selectKeysList [UserCompanyPersonalNumber ==. Just persNo] [] case candidates of - [uid] -> $logInfoS "AVS" "Matching user found, linking." >> insertUniqueEntity (UserAvs api uid) + [uid] -> $logInfoS "AVS" "Matching user found, linking." >> insertUniqueEntity (UserAvs api uid avsPersonPersonNo) (_:_) -> throwM AvsUserAmbiguous [] -> do upsRes :: Either CampusUserConversionException (Entity User) <- try $ ldapLookupAndUpsert persNo - $logInfoS "AVS" $ "No matching user found. attempted LDAP upsert returned: " <> tshow upsRes + $logInfoS "AVS" $ "No matching existing user found. Attempted LDAP upsert returned: " <> tshow upsRes case upsRes of - Right Entity{entityKey=uid} -> insertUniqueEntity $ UserAvs api uid -- pin/addr are updated in next step anyway + Right Entity{entityKey=uid} -> insertUniqueEntity $ UserAvs api uid avsPersonPersonNo -- pin/addr are updated in next step anyway _other -> return mbuid -- ==Nothing -- user could not be created somehow _other -> return mbuid case (mbuid, mbapd) of @@ -292,6 +292,7 @@ upsertAvsUserById api = do pinCard = Set.lookupMax avsPersonPersonCards userPin = tshowAvsFullCardNo . getFullCardNo <$> pinCard fakeIdent = CI.mk $ "AVSID:" <> tshow api + fakeNo = CI.mk $ "AVSNO:" <> tshow avsPersonPersonNo newUsr = AdminUserForm { aufTitle = Nothing , aufFirstName = avsPersonFirstName @@ -307,14 +308,14 @@ upsertAvsUserById api = do , aufPostAddress = userFirmAddr , aufPrefersPostal = isJust firmAddress , aufPinPassword = userPin - , aufEmail = fakeIdent -- Email is unknown in this version of the avs query, to be updated later (FUTURE TODO) + , aufEmail = fakeNo -- Email is unknown in this version of the avs query, to be updated later (FUTURE TODO) , aufIdent = fakeIdent -- use AvsPersonId instead , aufAuth = maybe AuthKindNoLogin (const AuthKindLDAP) avsPersonInternalPersonalNo -- FUTURE TODO: if email is known, use AuthKinfPWHash for email invite, if no internal personal number is known } mbUid <- addNewUser newUsr -- triggers JobSynchroniseLdapUser, JobSendPasswordReset and NotificationUserAutoModeUpdate -- TODO: check if these are failsafe whenIsJust mbUid $ \uid -> runDB $ do now <- liftIO getCurrentTime - insert_ $ UserAvs avsPersonPersonID uid + insert_ $ UserAvs avsPersonPersonID uid avsPersonPersonNo -- forM_ avsPersonPersonCards $ -- save all cards for later let cs :: Set AvsDataPersonCard = Set.fromList $ catMaybes [pinCard, addrCard] forM_ cs $ -- only save used cards for the postal address update detection diff --git a/src/Utils.hs b/src/Utils.hs index 8fa9a42b7..0213629d9 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -1057,6 +1057,16 @@ throwExceptT = exceptT throwM return generalFinally :: MonadMask m => m a -> (ExitCase a -> m b) -> m a generalFinally action finalizer = view _1 <$> generalBracket (return ()) (const finalizer) (const action) + +------------- +-- Functor -- +------------- + +infixl 4 <<$>> +(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b) +(<<$>>) f x = fmap f <$> x + + ------------ -- Monads -- ------------ diff --git a/src/Utils/Lens.hs b/src/Utils/Lens.hs index 0001b4dc3..eeabff294 100644 --- a/src/Utils/Lens.hs +++ b/src/Utils/Lens.hs @@ -125,6 +125,8 @@ makeClassyFor_ ''QualificationUser makeClassyFor_ ''LmsUser makeClassyFor_ ''LmsUserlist makeClassyFor_ ''LmsResult +makeClassyFor_ ''UserAvs +makeClassyFor_ ''UserAvsCard _entityKey :: Getter (Entity record) (Key record) -- ^ Not a `Lens'` for safety diff --git a/templates/profileData.hamlet b/templates/profileData.hamlet index 17d4f05fc..b84991a2d 100644 --- a/templates/profileData.hamlet +++ b/templates/profileData.hamlet @@ -11,9 +11,15 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
#{userIdent}
- _{MsgAuthModeSet} -
+ _{MsgAuthModeSet} +
_{userAuthentication} + $maybe avs <- avsId +
+ _{MsgAvsPersonNo} + ^{messageTooltip tooltipAvsPersNo} +
+ #{view _userAvsNoPerson avs}
_{MsgNameSet}
diff --git a/test/Database/Fill.hs b/test/Database/Fill.hs index 6f7a305a5..7fbe85af6 100644 --- a/test/Database/Fill.hs +++ b/test/Database/Fill.hs @@ -518,6 +518,7 @@ fillDb = do void . insert' $ UserSchool uid mi False for_ [jost] $ \uid -> void . insert' $ UserSchool uid avn False + void . insert' $ UserAvs (AvsPersonId 12345678) jost 87654321 let f_descr = Just $ htmlToStoredMarkup [shamlet|

Berechtigung zum Führen eines Fahrzeuges auf den Fahrstrassen des Vorfeldes.|] let r_descr = Just $ htmlToStoredMarkup [shamlet|

Berechtigung zum Führen eines Fahrzeuges auf dem gesamten Rollfeld.|]