diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 3e907dc..2d8df8b 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -118,25 +118,20 @@ instance Yesod App where -- Who can access which pages. isAuthorized r w = case (r, w) of (GroupsR , True) -> loggedIn - (GroupNewR , _) -> loggedIn - (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" + (GroupNewR , _) -> loggedIn + (ProjectNewR user , _) -> loggedInAs user + (RepoNewR user , _) -> loggedInAs user + (KeysR , _) -> loggedIn + (KeyR _key , _) -> loggedIn + (KeyNewR , _) -> loggedIn + (RepoR shar _ , True) -> loggedInAs shar + (TicketNewR _ _ , _) -> loggedIn + (TicketR user _ _ , True) -> loggedInAs user + (TicketEditR user _ _ , _) -> loggedInAs user (TicketDiscussionR _ _ _ , True) -> loggedIn - (TicketTopReplyR _ _ _ , _) -> loggedIn - (TicketReplyR _ _ _ _ , _) -> loggedIn - _ -> return Authorized + (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 @@ -229,8 +224,8 @@ loggedIn = do Nothing -> return AuthenticationRequired Just _pid -> return Authorized -loggedInAs :: ShrIdent -> Text -> Handler AuthResult -loggedInAs ident msg = do +loggedInAs :: ShrIdent -> Handler AuthResult +loggedInAs ident = do mp <- maybeAuth case mp of Nothing -> return AuthenticationRequired @@ -243,9 +238,9 @@ loggedInAs ident msg = do personLogin person <> " specified a nonexistent sharer ID" Just sharer -> - if ident == sharerIdent sharer - then return Authorized - else return $ Unauthorized msg + return $ if ident == sharerIdent sharer + then Authorized + else Unauthorized "No access to this operation" instance YesodBreadcrumbs App where breadcrumb route = return $ case route of