|
|
|
|
@ -21,10 +21,7 @@ import qualified Network.Wai as W (pathInfo)
|
|
|
|
|
|
|
|
|
|
import Yesod.Core.Types (Logger)
|
|
|
|
|
import qualified Yesod.Core.Unsafe as Unsafe
|
|
|
|
|
import Data.CaseInsensitive (CI)
|
|
|
|
|
import qualified Data.CaseInsensitive as CI
|
|
|
|
|
|
|
|
|
|
import qualified Data.CryptoID as E
|
|
|
|
|
import Data.CaseInsensitive (original, mk)
|
|
|
|
|
|
|
|
|
|
import Data.ByteArray (convert)
|
|
|
|
|
import Crypto.Hash (Digest, SHAKE256, SHAKE128)
|
|
|
|
|
@ -91,20 +88,13 @@ import qualified Data.Aeson as JSON
|
|
|
|
|
import Data.FileEmbed (embedFile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- TODO: remove once CryptoID is an instance of ToMarkup
|
|
|
|
|
instance DisplayAble b => DisplayAble (E.CryptoID a b) where
|
|
|
|
|
display = display . ciphertext
|
|
|
|
|
|
|
|
|
|
instance {-# OVERLAPS #-} namespace ~ CryptoIDNamespace (CI FilePath) SubmissionId => DisplayAble (E.CryptoID namespace (CI FilePath)) where
|
|
|
|
|
display = toPathPiece
|
|
|
|
|
|
|
|
|
|
-- TODO: remove
|
|
|
|
|
instance DisplayAble TermId where
|
|
|
|
|
display = termToText . unTermKey
|
|
|
|
|
|
|
|
|
|
-- TODO: remove
|
|
|
|
|
instance DisplayAble SchoolId where
|
|
|
|
|
display = CI.original . unSchoolKey
|
|
|
|
|
display = original . unSchoolKey
|
|
|
|
|
|
|
|
|
|
type SMTPPool = Pool SMTPConnection
|
|
|
|
|
|
|
|
|
|
@ -1451,11 +1441,11 @@ instance YesodBreadcrumbs UniWorX where
|
|
|
|
|
breadcrumb (TermEditExistR tid) = return ("Editieren" , Just $ TermCourseListR tid)
|
|
|
|
|
breadcrumb (TermCourseListR (unTermKey -> tid)) = getMessageRender <&> \mr -> (mr $ ShortTermIdentifier tid, Just CourseListR)
|
|
|
|
|
|
|
|
|
|
breadcrumb (TermSchoolCourseListR tid ssh) = return (CI.original $ unSchoolKey ssh, Just $ TermCourseListR tid)
|
|
|
|
|
breadcrumb (TermSchoolCourseListR tid ssh) = return (original $ unSchoolKey ssh, Just $ TermCourseListR tid)
|
|
|
|
|
|
|
|
|
|
breadcrumb CourseListR = return ("Kurse" , Nothing)
|
|
|
|
|
breadcrumb CourseNewR = return ("Neu" , Just CourseListR)
|
|
|
|
|
breadcrumb (CourseR tid ssh csh CShowR) = return (CI.original csh, Just $ TermSchoolCourseListR tid ssh)
|
|
|
|
|
breadcrumb (CourseR tid ssh csh CShowR) = return (original csh, Just $ TermSchoolCourseListR tid ssh)
|
|
|
|
|
-- (CourseR tid ssh csh CRegisterR) -- is POST only
|
|
|
|
|
breadcrumb (CourseR tid ssh csh CEditR) = return ("Editieren" , Just $ CourseR tid ssh csh CShowR)
|
|
|
|
|
breadcrumb (CourseR tid ssh csh CUsersR) = return ("Anmeldungen", Just $ CourseR tid ssh csh CShowR)
|
|
|
|
|
@ -1472,12 +1462,12 @@ instance YesodBreadcrumbs UniWorX where
|
|
|
|
|
breadcrumb (CourseR tid ssh csh CTutorialListR) = return ("Tutorien", Just $ CourseR tid ssh csh CShowR)
|
|
|
|
|
breadcrumb (CourseR tid ssh csh CTutorialNewR) = return ("Anlegen", Just $ CourseR tid ssh csh CTutorialListR)
|
|
|
|
|
|
|
|
|
|
breadcrumb (CTutorialR tid ssh csh tutn TUsersR) = return (CI.original tutn, Just $ CourseR tid ssh csh CTutorialListR)
|
|
|
|
|
breadcrumb (CTutorialR tid ssh csh tutn TUsersR) = return (original tutn, Just $ CourseR tid ssh csh CTutorialListR)
|
|
|
|
|
breadcrumb (CTutorialR tid ssh csh tutn TEditR) = return ("Bearbeiten", Just $ CTutorialR tid ssh csh tutn TUsersR)
|
|
|
|
|
breadcrumb (CTutorialR tid ssh csh tutn TDeleteR) = return ("Löschen", Just $ CTutorialR tid ssh csh tutn TUsersR)
|
|
|
|
|
breadcrumb (CTutorialR tid ssh csh tutn TCommR) = return ("Mitteilung", Just $ CTutorialR tid ssh csh tutn TUsersR)
|
|
|
|
|
|
|
|
|
|
breadcrumb (CSheetR tid ssh csh shn SShowR) = return (CI.original shn, Just $ CourseR tid ssh csh SheetListR)
|
|
|
|
|
breadcrumb (CSheetR tid ssh csh shn SShowR) = return (original shn, Just $ CourseR tid ssh csh SheetListR)
|
|
|
|
|
breadcrumb (CSheetR tid ssh csh shn SEditR) = return ("Bearbeiten" , Just $ CSheetR tid ssh csh shn SShowR)
|
|
|
|
|
breadcrumb (CSheetR tid ssh csh shn SDelR ) = return ("Löschen" , Just $ CSheetR tid ssh csh shn SShowR)
|
|
|
|
|
breadcrumb (CSheetR tid ssh csh shn SSubsR) = return ("Abgaben" , Just $ CSheetR tid ssh csh shn SShowR)
|
|
|
|
|
@ -1493,7 +1483,7 @@ instance YesodBreadcrumbs UniWorX where
|
|
|
|
|
|
|
|
|
|
breadcrumb (CourseR tid ssh csh MaterialListR) = return ("Material" , Just $ CourseR tid ssh csh CShowR)
|
|
|
|
|
breadcrumb (CourseR tid ssh csh MaterialNewR ) = return ("Neu" , Just $ CourseR tid ssh csh MaterialListR)
|
|
|
|
|
breadcrumb (CMaterialR tid ssh csh mnm MShowR) = return (CI.original mnm, Just $ CourseR tid ssh csh MaterialListR)
|
|
|
|
|
breadcrumb (CMaterialR tid ssh csh mnm MShowR) = return (original mnm, Just $ CourseR tid ssh csh MaterialListR)
|
|
|
|
|
breadcrumb (CMaterialR tid ssh csh mnm MEditR) = return ("Bearbeiten" , Just $ CMaterialR tid ssh csh mnm MShowR)
|
|
|
|
|
breadcrumb (CMaterialR tid ssh csh mnm MDelR) = return ("Löschen" , Just $ CMaterialR tid ssh csh mnm MShowR)
|
|
|
|
|
-- (CMaterialR tid ssh csh mnm MFileR) -- just for Downloads
|
|
|
|
|
@ -2005,8 +1995,8 @@ pageActions (CourseR tid ssh csh SheetListR) =
|
|
|
|
|
, menuItemLabel = MsgMenuCorrectionsOwn
|
|
|
|
|
, menuItemIcon = Nothing
|
|
|
|
|
, menuItemRoute = SomeRoute (CorrectionsR, [ ("corrections-term" , termToText $ unTermKey tid)
|
|
|
|
|
, ("corrections-school", CI.original $ unSchoolKey ssh)
|
|
|
|
|
, ("corrections-course", CI.original csh)
|
|
|
|
|
, ("corrections-school", original $ unSchoolKey ssh)
|
|
|
|
|
, ("corrections-course", original csh)
|
|
|
|
|
])
|
|
|
|
|
, menuItemModal = False
|
|
|
|
|
, menuItemAccessCallback' = do
|
|
|
|
|
@ -2146,9 +2136,9 @@ pageActions (CSheetR tid ssh csh shn SShowR) =
|
|
|
|
|
, menuItemLabel = MsgMenuCorrectionsOwn
|
|
|
|
|
, menuItemIcon = Nothing
|
|
|
|
|
, menuItemRoute = SomeRoute (CorrectionsR, [ ("corrections-term" , termToText $ unTermKey tid)
|
|
|
|
|
, ("corrections-school", CI.original $ unSchoolKey ssh)
|
|
|
|
|
, ("corrections-course", CI.original csh)
|
|
|
|
|
, ("corrections-sheet" , CI.original shn)
|
|
|
|
|
, ("corrections-school", original $ unSchoolKey ssh)
|
|
|
|
|
, ("corrections-course", original csh)
|
|
|
|
|
, ("corrections-sheet" , original shn)
|
|
|
|
|
])
|
|
|
|
|
, menuItemModal = False
|
|
|
|
|
, menuItemAccessCallback' = (== Authorized) <$> evalAccessCorrector tid ssh csh
|
|
|
|
|
@ -2499,7 +2489,7 @@ routeNormalizers =
|
|
|
|
|
tell $ Any True
|
|
|
|
|
maybeOrig f route = maybeT (return route) $ f route
|
|
|
|
|
hasChanged a b
|
|
|
|
|
| ((/=) `on` CI.original) a b = do
|
|
|
|
|
| ((/=) `on` original) a b = do
|
|
|
|
|
$logDebugS "routeNormalizers" [st|#{tshow a} /= #{tshow b}|]
|
|
|
|
|
tell $ Any True
|
|
|
|
|
| otherwise = return ()
|
|
|
|
|
@ -2565,7 +2555,7 @@ instance YesodAuth UniWorX where
|
|
|
|
|
now <- liftIO getCurrentTime
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
userIdent = CI.mk credsIdent
|
|
|
|
|
userIdent = mk credsIdent
|
|
|
|
|
uAuth = UniqueAuthentication userIdent
|
|
|
|
|
|
|
|
|
|
isDummy = credsPlugin == "dummy"
|
|
|
|
|
@ -2603,7 +2593,7 @@ instance YesodAuth UniWorX where
|
|
|
|
|
|
|
|
|
|
flip catches excHandlers $ case (,) <$> appLdapConf <*> appLdapPool of
|
|
|
|
|
Just (ldapConf, ldapPool) -> fmap (either id id) . runExceptT $ do
|
|
|
|
|
ldapData <- campusUser ldapConf ldapPool $ Creds credsPlugin (CI.original userIdent) credsExtra
|
|
|
|
|
ldapData <- campusUser ldapConf ldapPool $ Creds credsPlugin (original userIdent) credsExtra
|
|
|
|
|
$logDebugS "LDAP" $ "Successful LDAP lookup: " <> tshow ldapData
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
@ -2620,7 +2610,7 @@ instance YesodAuth UniWorX where
|
|
|
|
|
userEmail <- if
|
|
|
|
|
| Just [bs] <- userEmail'
|
|
|
|
|
, Right userEmail <- Text.decodeUtf8' bs
|
|
|
|
|
-> return $ CI.mk userEmail
|
|
|
|
|
-> return $ mk userEmail
|
|
|
|
|
| otherwise
|
|
|
|
|
-> throwError $ ServerError "Could not retrieve user email"
|
|
|
|
|
userDisplayName <- if
|
|
|
|
|
@ -2675,7 +2665,7 @@ instance YesodAuth UniWorX where
|
|
|
|
|
Right str <- return $ Text.decodeUtf8' v'
|
|
|
|
|
return str
|
|
|
|
|
|
|
|
|
|
termNames = nubBy ((==) `on` CI.mk) $ do
|
|
|
|
|
termNames = nubBy ((==) `on` mk) $ do
|
|
|
|
|
(k, v) <- ldapData
|
|
|
|
|
guard $ k == Attr "dfnEduPersonFieldOfStudyString"
|
|
|
|
|
v' <- v
|
|
|
|
|
|