diff --git a/frontend/src/app.js b/frontend/src/app.js index 56df924..3849d53 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -23,7 +23,9 @@ export class App extends Component { - + } /> diff --git a/frontend/src/components/AuthorizedRoute.js b/frontend/src/components/AuthorizedRoute.js index 9d7c6f5..31014a1 100644 --- a/frontend/src/components/AuthorizedRoute.js +++ b/frontend/src/components/AuthorizedRoute.js @@ -1,7 +1,23 @@ import { Route } from 'react-router'; +import PropTypes from 'prop-types'; + +export function AuthorizedRoute({ required, roles, ...props}) { + if ( !roles.includes(required) ) { + return ( + + + Vous ne pouvez pas accéder à cette page. + + + ); + } -export function AuthorizedRoute({...props}) { return ( - ) + ); } + +AuthorizedRoute.propTypes = { + required: PropTypes.string.isRequired, + roles: PropTypes.arrayOf(PropTypes.string).isRequired +};