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
loggedInAs user "You cant create projects for other users" (ProjectNewR user , _) ->
isAuthorized (RepoNewR user) _ = loggedInAs user "You cant create projects for other users"
loggedInAs user "You cant create repos for other users" (RepoNewR user , _) ->
isAuthorized KeysR _ = loggedIn loggedInAs user "You cant create repos for other users"
isAuthorized (KeyR _key) _ = loggedIn (KeysR , _) -> loggedIn
isAuthorized KeyNewR _ = loggedIn (KeyR _key , _) -> loggedIn
isAuthorized (RepoR shar _) True = (KeyNewR , _) -> loggedIn
loggedInAs shar "You cant modify repos for other users" (RepoR shar _ , True) ->
isAuthorized (TicketNewR _ _) _ = loggedIn loggedInAs shar "You cant modify repos for other users"
isAuthorized (TicketR user _ _) True = (TicketNewR _ _ , _) -> loggedIn
loggedInAs user "Only project members can modify this ticket" (TicketR user _ _ , True) ->
isAuthorized (TicketEditR user _ _) _ = loggedInAs user "Only project members can modify this ticket"
loggedInAs user "Only project members can modify this ticket" (TicketEditR user _ _ , _) ->
isAuthorized (TicketDiscussionR _ _ _) True = loggedIn loggedInAs user "Only project members can modify this ticket"
isAuthorized (TicketTopReplyR _ _ _) _ = loggedIn (TicketDiscussionR _ _ _ , True) -> loggedIn
isAuthorized (TicketReplyR _ _ _ _) _ = loggedIn (TicketTopReplyR _ _ _ , _) -> loggedIn
isAuthorized _ _ = return Authorized (TicketReplyR _ _ _ _ , _) -> loggedIn
_ -> 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