You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
506 B

  1. import _ from 'lodash'
  2. export default _.debounce(async function({ app, store, route, redirect }) {
  3. try {
  4. await store.dispatch('projects/setCurrentProject', route.params.id)
  5. } catch(e) {
  6. redirect('/projects')
  7. }
  8. const role = store.getters['projects/getCurrentUserRole']
  9. const projectRoot = app.localePath('/projects/' + route.params.id)
  10. const path = route.fullPath.replace(/\/$/g, '')
  11. if (!role.is_project_admin && path !== projectRoot) {
  12. return redirect(projectRoot)
  13. }
  14. }, 1000)