fix(auth): wrong caching for external-exam-staff

This commit is contained in:
Gregor Kleen 2021-03-19 14:20:49 +01:00
parent 72191315b6
commit 9d1f1c6910
3 changed files with 7 additions and 2 deletions

View File

@ -401,7 +401,7 @@ data AuthorizationCacheKey
| AuthCacheWorkflowInstanceInitiators WorkflowInstanceName RouteWorkflowScope
| AuthCacheWorkflowInstanceWorkflowViewers WorkflowInstanceName RouteWorkflowScope
| AuthCacheSchoolFunctionList SchoolFunction | AuthCacheSystemFunctionList SystemFunction
| AuthCacheLecturerList | AuthCacheCorrectorList | AuthCacheExamCorrectorList | AuthCacheTutorList | AuthCacheSubmissionGroupUserList
| AuthCacheLecturerList | AuthCacheExternalExamStaffList | AuthCacheCorrectorList | AuthCacheExamCorrectorList | AuthCacheTutorList | AuthCacheSubmissionGroupUserList
| AuthCacheCourseRegisteredList TermId SchoolId CourseShorthand
deriving (Eq, Ord, Read, Show, Generic, Typeable)
deriving anyclass (Hashable, Binary)
@ -660,7 +660,10 @@ tagAccessPredicate AuthLecturer = cacheAP' (Just $ Right diffMinute) mkLecturerL
mkLecturerList _ route _ = case route of
CourseR{} -> cacheLecturerList
AllocationR{} -> cacheLecturerList
EExamR{} -> cacheLecturerList
EExamR{} -> Just
( AuthCacheExternalExamStaffList
, runDBRead . fmap (setOf $ folded . _Value) . E.select . E.from $ return . (E.^. ExternalExamStaffUser)
)
_other -> Just
( AuthCacheSchoolFunctionList SchoolLecturer
, runDBRead . fmap (setOf $ folded . _Value) . E.select . E.from $ \userFunction -> do

View File

@ -55,6 +55,7 @@ postEEEditR tid ssh coursen examn = do
when (is _Nothing replaceRes) $ do
audit $ TransactionExternalExamEdit eeId
memcachedByInvalidate AuthCacheExternalExamStaffList $ Proxy @(Set UserId)
forM_ (eefStaff `setSymmDiff` staff) $ \change -> if
| change `Set.member` eefStaff -> case change of
Left invEmail -> do

View File

@ -42,6 +42,7 @@ postEExamNewR = do
forM_ eefOfficeSchools' $ \ExternalExamOfficeSchool{..} ->
audit $ TransactionExternalExamOfficeSchoolEdit eeId externalExamOfficeSchoolSchool
memcachedByInvalidate AuthCacheExternalExamStaffList $ Proxy @(Set UserId)
let (invites, adds) = partitionEithers $ Set.toList eefStaff
eefStaff' = do
externalExamStaffUser <- adds