BUGFIX, Attempt 2: Authorization for Admins without schools fixed.

This commit is contained in:
SJost 2017-11-27 16:54:12 +01:00
parent 5886b99bfc
commit 4686c63fd9
2 changed files with 10 additions and 10 deletions

View File

@ -204,21 +204,21 @@ submissionAccess cID = do
adminAccess :: Maybe (Maybe SchoolId) -- ^ If @Just@, matched exactly against 'userAdminSchool'
-> YesodDB UniWorX AuthResult
adminAccess school = do
adminAccess school = do
authId <- lift requireAuthId
schools <- map (userAdminSchool . entityVal) <$> selectList [UserAdminUser ==. authId] []
return $ case maybe (null schools) (`elem` schools) school of
True -> Authorized
False -> Unauthorized "No admin access"
rights <- selectList [UserAdminUser ==. authId, UserAdminSchool <-. catMaybes [school,Just Nothing]] []
return $ if (not $ null rights)
then Authorized
else Unauthorized "No admin access"
lecturerAccess :: Maybe SchoolId
-> YesodDB UniWorX AuthResult
lecturerAccess school = do
authId <- lift requireAuthId
schools <- map (userLecturerSchool . entityVal) <$> selectList [UserLecturerUser ==. authId] []
return $ case maybe (null schools) (`elem` schools) school of
True -> Authorized
False -> Unauthorized "No lecturer access"
rights <- selectList ((UserLecturerUser ==. authId) : maybe [] (\s -> [UserLecturerSchool ==. s]) school) []
return $ if (not $ null rights)
then Authorized
else Unauthorized "No lecturer access"
courseLecturerAccess :: CourseId -> YesodDB UniWorX AuthResult
courseLecturerAccess courseId = do

View File

@ -73,7 +73,7 @@ getCourseListTermR tidini = do
defaultLinkLayout pageLinks $ do
-- defaultLayout $ do
setTitle "Semesterkurse"
-- linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
linkButton "Neuen Kurs anlegen" BCPrimary CourseEditR
encodeHeadedWidgetTable tableDefault colonnadeTerms courses -- (map entityVal courses)
getCourseShowR :: TermIdentifier -> Text -> Handler Html