diff --git a/app/authsome_editoria.js b/app/authsome_editoria.js index 22267f440eaeaa544719b1d5e5de259c4408f09b..473aa79d89effa7f4caaf73441a164593d1df8fb 100644 --- a/app/authsome_editoria.js +++ b/app/authsome_editoria.js @@ -55,6 +55,8 @@ var editoria = function (user, operation, object) { if (!user) return false if (user.admin) return true + if (operation === 'admin') return false + // object might be an array of objects (eg. teams, users, etc.) // pick up if that is the case and use the first one to define the type of those objects if (Array.isArray(object)) { diff --git a/app/components/Navigation/Navigation.jsx b/app/components/Navigation/Navigation.jsx index 18c7d5f85681c21ad209f01c4f4b7091431f8de6..673ecb095546fcd633d8ddf4174572276ddb8a0e 100644 --- a/app/components/Navigation/Navigation.jsx +++ b/app/components/Navigation/Navigation.jsx @@ -48,18 +48,17 @@ export default class Navigation extends React.Component { <NavItem>Books</NavItem> </LinkContainer> - <Authorize operation='read' object={currentUser.user}> + <Authorize operation='read' object='users'> <LinkContainer to='/users'> <NavItem>Users</NavItem> </LinkContainer> </Authorize> - <Authorize operation='read'> + <Authorize operation='read' object='teams'> <LinkContainer to='/teams'> <NavItem>Teams</NavItem> </LinkContainer> </Authorize> - </Nav> { logoutButtonIfAuthenticated } diff --git a/app/main.scss b/app/main.scss deleted file mode 100644 index bdf2996588590552fe200fd7d0e8ce90e77c492b..0000000000000000000000000000000000000000 --- a/app/main.scss +++ /dev/null @@ -1,7 +0,0 @@ -// @import '~pubsweet-component-pepper-theme/main'; - -// $icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/'; -// -// .bootstrap { -// @import '~bootstrap-sass/assets/stylesheets/_bootstrap'; -// } diff --git a/app/routes.jsx b/app/routes.jsx index 93c2e0c56f4644f623c6d7ef10481c0a859a144c..2f2b463f197b0b904b5d3c582f4e8e1fe28e06f1 100644 --- a/app/routes.jsx +++ b/app/routes.jsx @@ -22,6 +22,14 @@ const AuthenticatedManage = requireAuthentication( Manage, 'create', (state) => state.collections[0] ) +const AdminOnlyUsersManager = requireAuthentication( + UsersManager, 'admin', (state) => state.collections[0] +) + +const AdminOnlyTeamsManager = requireAuthentication( + TeamsManager, 'admin', (state) => state.collections[0] +) + export default ( <Route> <Redirect from='/' to='books' /> @@ -33,11 +41,13 @@ export default ( <Route path='books/:id/book-builder' component={BookBuilder} /> <Route path='books/:bookId/fragments/:fragmentId' component={SimpleEditorWrapper} /> - <Route path='users' component={UsersManager} /> - <Route path='teams' component={TeamsManager} /> + <Route path='users' component={AdminOnlyUsersManager} /> + <Route path='teams' component={AdminOnlyTeamsManager} /> </Route> <Route path='/login' component={Login} /> <Route path='/signup' component={Signup} /> + + <Redirect path='*' to='books' /> </Route> )