chore: use requireAuthPair (+ fix type errors)
This commit is contained in:
parent
d6e39fb07c
commit
16abbc5da9
@ -36,14 +36,12 @@ postCNotesR _ _ _ = defaultLayout [whamlet|You have corrector access to this cou
|
||||
|
||||
postCFavouriteR :: TermId -> SchoolId -> CourseShorthand -> Handler ()
|
||||
postCFavouriteR tid ssh csh = void $ do
|
||||
muid <- maybeAuthPair
|
||||
authPair@(uid, _) <- requireAuthPair
|
||||
runDB $ void $ do
|
||||
mcid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
||||
if | Just cid <- mcid, Just uid <- view _1 <$> muid -> do
|
||||
cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
||||
now <- liftIO getCurrentTime
|
||||
-- Nothing means blacklist
|
||||
-- should never return FavouriteCurrent
|
||||
newReason <- storedFavouriteReason tid ssh csh muid <&> (\case
|
||||
newReason <- storedFavouriteReason tid ssh csh (Just authPair) <&> (\case
|
||||
-- Maybe (Maybe reason, blacklist)
|
||||
Nothing -> Just FavouriteManual
|
||||
Just (_reason, True) -> Just FavouriteVisited
|
||||
@ -63,6 +61,5 @@ postCFavouriteR tid ssh csh = void $ do
|
||||
(UniqueCourseNoFavourite uid cid)
|
||||
(CourseNoFavourite uid cid)
|
||||
[] -- entry shouldn't exists, but keep it unchanged anyway
|
||||
| otherwise -> pure ()
|
||||
-- show course page again
|
||||
redirect $ CourseR tid ssh csh CShowR
|
||||
|
||||
Reference in New Issue
Block a user