Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could I use this out of Vue Component? #60

Open
thearabbit opened this issue Feb 20, 2018 · 6 comments
Open

Could I use this out of Vue Component? #60

thearabbit opened this issue Feb 20, 2018 · 6 comments

Comments

@thearabbit
Copy link

thearabbit commented Feb 20, 2018

I base on Meteor.
I check Progressbar on Meteor Startup

import VueProgressBar from 'vue-progressbar'

Meteor.startup(() => {
  // Before each
  router.beforeEach((to, from, next) => {
    VueProgressBar.start()

    if (!to.meta.notRequiresAuth) {
      // Check user
      if (!Meteor.loggingIn() && !Meteor.userId()) {
        next({ path: '/login' })
      } else {
        next()
      }
    } else {
      next()
    }
  })

  // // After each
  router.afterEach((to, from) => {
    VueProgressBar.finish()
  })

  // Start the vue app
  new Vue({
    router,
    store,
    ...AppLayout,
  }).$mount('app')
})

Bc I use check router hook in App Layout don't work

@malinbranduse
Copy link
Contributor

@thearabbit Haven't tested it but you could do something like this:

import VueProgressBar from 'vue-progressbar'
Vue.use(VueProgressBar )

Meteor.startup(() => {
  // Start the vue app
  const app = new Vue({
    store,
    ...AppLayout,
  }).$mount('app')

  // Before each
  app.$router.beforeEach((to, from, next) => {
    app.$Progress.start()

    if (!to.meta.notRequiresAuth) {
      // Check user
      if (!Meteor.loggingIn() && !Meteor.userId()) {
        next({ path: '/login' })
      } else {
        next()
      }
    } else {
      next()
    }
  })

  // // After each
  app.$router.afterEach((to, from) => {
    app.$Progress.finish()
  })
})

@thearabbit
Copy link
Author

Thank for your reply, I will try soon

@thearabbit
Copy link
Author

thearabbit commented Feb 22, 2018

It work for Progressbar, but don't work my Authentication

@thearabbit
Copy link
Author

Have any solve?

@thearabbit
Copy link
Author

Waiting...

@rijkvanzanten
Copy link

Is your authentication a route change within Vue, or do you only initialize Vue itself after the user has logged in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants