Reduce verbosity of isAuthorized

This commit is contained in:
fr33domlover 2016-05-25 06:53:22 +00:00
parent bc66463776
commit 01915e6df9

View file

@ -116,24 +116,25 @@ instance Yesod App where
authRoute _ = Just $ AuthR LoginR authRoute _ = Just $ AuthR LoginR
-- Who can access which pages. -- Who can access which pages.
isAuthorized (ProjectNewR user) _ = isAuthorized r w = case (r, w) of
(ProjectNewR user , _) ->
loggedInAs user "You cant create projects for other users" loggedInAs user "You cant create projects for other users"
isAuthorized (RepoNewR user) _ = (RepoNewR user , _) ->
loggedInAs user "You cant create repos for other users" loggedInAs user "You cant create repos for other users"
isAuthorized KeysR _ = loggedIn (KeysR , _) -> loggedIn
isAuthorized (KeyR _key) _ = loggedIn (KeyR _key , _) -> loggedIn
isAuthorized KeyNewR _ = loggedIn (KeyNewR , _) -> loggedIn
isAuthorized (RepoR shar _) True = (RepoR shar _ , True) ->
loggedInAs shar "You cant modify repos for other users" loggedInAs shar "You cant modify repos for other users"
isAuthorized (TicketNewR _ _) _ = loggedIn (TicketNewR _ _ , _) -> loggedIn
isAuthorized (TicketR user _ _) True = (TicketR user _ _ , True) ->
loggedInAs user "Only project members can modify this ticket" loggedInAs user "Only project members can modify this ticket"
isAuthorized (TicketEditR user _ _) _ = (TicketEditR user _ _ , _) ->
loggedInAs user "Only project members can modify this ticket" loggedInAs user "Only project members can modify this ticket"
isAuthorized (TicketDiscussionR _ _ _) True = loggedIn (TicketDiscussionR _ _ _ , True) -> loggedIn
isAuthorized (TicketTopReplyR _ _ _) _ = loggedIn (TicketTopReplyR _ _ _ , _) -> loggedIn
isAuthorized (TicketReplyR _ _ _ _) _ = loggedIn (TicketReplyR _ _ _ _ , _) -> loggedIn
isAuthorized _ _ = return Authorized _ -> return Authorized
-- This function creates static content files in the static folder -- This function creates static content files in the static folder
-- and names them based on a hash of their content. This allows -- and names them based on a hash of their content. This allows