Copyright | (c) digitally induced GmbH 2020 |
---|---|
Safe Haskell | Safe-Inferred |
IHP.AuthSupport.Authorization
Description
Synopsis
- class CanView user model where
- canView :: (?modelContext :: ModelContext) => model -> user -> IO Bool
- accessDeniedUnless :: Bool -> IO ()
Documentation
accessDeniedUnless :: Bool -> IO () Source #
Stops the action execution with an error message when the access condition is false.
Example: Checking a user is author of a blog post.
action EditPostAction { postId } = do post <- fetch postId accessDeniedUnless (get #authorId post == currentUserId) renderHtml EditView { .. }
This will throw an error and prevent the view from being rendered when the current user is not author of the post.