web: Add missing capability guards to /manage and /download
This commit is contained in:
parent
1df2cfb322
commit
8d1ee38627
@ -23,13 +23,16 @@ getRootR = redirect JournalR
|
|||||||
|
|
||||||
getManageR :: Handler Html
|
getManageR :: Handler Html
|
||||||
getManageR = do
|
getManageR = do
|
||||||
VD{j} <- getViewData
|
VD{caps, j} <- getViewData
|
||||||
|
when (CapManage `notElem` caps) (permissionDenied "Missing the 'manage' capability")
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Manage journal"
|
setTitle "Manage journal"
|
||||||
$(widgetFile "manage")
|
$(widgetFile "manage")
|
||||||
|
|
||||||
getDownloadR :: FilePath -> Handler TypedContent
|
getDownloadR :: FilePath -> Handler TypedContent
|
||||||
getDownloadR f = do
|
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' <> "\"")
|
addHeader "Content-Disposition" ("attachment; filename=\"" <> T.pack f' <> "\"")
|
||||||
sendResponse ("text/plain" :: ByteString, toContent txt)
|
sendResponse ("text/plain" :: ByteString, toContent txt)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user