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.

19 lines
635 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 userId = store.getters['auth/getUserId']
  9. const isProjectAdmin = await app.$services.member.isProjectAdmin(route.params.id, userId)
  10. const projectRoot = app.localePath('/projects/' + route.params.id)
  11. const path = route.fullPath.replace(/\/$/g, '')
  12. if (isProjectAdmin || path === projectRoot || path.startsWith(projectRoot + '/dataset')) {
  13. return
  14. }
  15. return redirect(projectRoot)
  16. }, 1000)