web: Add missing capability guards to /manage and /download

This commit is contained in:
Jakub Zárybnický 2018-06-24 23:17:56 +02:00
parent 1df2cfb322
commit 8d1ee38627

View File

@ -23,13 +23,16 @@ getRootR = redirect JournalR
getManageR :: Handler Html
getManageR = do
VD{j} <- getViewData
VD{caps, j} <- getViewData
when (CapManage `notElem` caps) (permissionDenied "Missing the 'manage' capability")
defaultLayout $ do
setTitle "Manage journal"
$(widgetFile "manage")
getDownloadR :: FilePath -> Handler TypedContent
getDownloadR f = do
(f', txt) <- journalFile404 f . j =<< getViewData
VD{caps, j} <- getViewData
when (CapManage `notElem` caps) (permissionDenied "Missing the 'manage' capability")
(f', txt) <- journalFile404 f j
addHeader "Content-Disposition" ("attachment; filename=\"" <> T.pack f' <> "\"")
sendResponse ("text/plain" :: ByteString, toContent txt)