mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 18:14:52 +09:00
Reduce verbosity of isAuthorized
This commit is contained in:
parent
bc66463776
commit
01915e6df9
1 changed files with 19 additions and 18 deletions
|
@ -116,24 +116,25 @@ instance Yesod App where
|
|||
authRoute _ = Just $ AuthR LoginR
|
||||
|
||||
-- Who can access which pages.
|
||||
isAuthorized (ProjectNewR user) _ =
|
||||
loggedInAs user "You can’t create projects for other users"
|
||||
isAuthorized (RepoNewR user) _ =
|
||||
loggedInAs user "You can’t create repos for other users"
|
||||
isAuthorized KeysR _ = loggedIn
|
||||
isAuthorized (KeyR _key) _ = loggedIn
|
||||
isAuthorized KeyNewR _ = loggedIn
|
||||
isAuthorized (RepoR shar _) True =
|
||||
loggedInAs shar "You can’t modify repos for other users"
|
||||
isAuthorized (TicketNewR _ _) _ = loggedIn
|
||||
isAuthorized (TicketR user _ _) True =
|
||||
loggedInAs user "Only project members can modify this ticket"
|
||||
isAuthorized (TicketEditR user _ _) _ =
|
||||
loggedInAs user "Only project members can modify this ticket"
|
||||
isAuthorized (TicketDiscussionR _ _ _) True = loggedIn
|
||||
isAuthorized (TicketTopReplyR _ _ _) _ = loggedIn
|
||||
isAuthorized (TicketReplyR _ _ _ _) _ = loggedIn
|
||||
isAuthorized _ _ = return Authorized
|
||||
isAuthorized r w = case (r, w) of
|
||||
(ProjectNewR user , _) ->
|
||||
loggedInAs user "You can’t create projects for other users"
|
||||
(RepoNewR user , _) ->
|
||||
loggedInAs user "You can’t create repos for other users"
|
||||
(KeysR , _) -> loggedIn
|
||||
(KeyR _key , _) -> loggedIn
|
||||
(KeyNewR , _) -> loggedIn
|
||||
(RepoR shar _ , True) ->
|
||||
loggedInAs shar "You can’t modify repos for other users"
|
||||
(TicketNewR _ _ , _) -> loggedIn
|
||||
(TicketR user _ _ , True) ->
|
||||
loggedInAs user "Only project members can modify this ticket"
|
||||
(TicketEditR user _ _ , _) ->
|
||||
loggedInAs user "Only project members can modify this ticket"
|
||||
(TicketDiscussionR _ _ _ , True) -> loggedIn
|
||||
(TicketTopReplyR _ _ _ , _) -> loggedIn
|
||||
(TicketReplyR _ _ _ _ , _) -> loggedIn
|
||||
_ -> return Authorized
|
||||
|
||||
-- This function creates static content files in the static folder
|
||||
-- and names them based on a hash of their content. This allows
|
||||
|
|
Loading…
Reference in a new issue