I dont know if that is the purpose of Install function but the fact is when I login
this.$auth.login(this.user, false, '/index');
Im being redirected correctly, then I refresh the page but the function install is being called again and the $auth.data gets lost. set to null.
return function install (Vue, options, router) {
var auth = new Vue(Auth)
console.log('installing auth');
console.log('from install' , auth.$data);
auth.setOptions(options || {})
Object.defineProperties(Vue.prototype, {
$auth: {
get () {
_setRoute.call(auth, this.$route, this.$router)
return auth
}
}
});`
.....
var Vue = require('vue');
var VueRouter = require('vue-router');
var resource = require('vue-resource');
Vue.config.debug = true;
Vue.use(resource);
Vue.use(VueRouter);
import App from './App.vue'
var router = new VueRouter(
{
hashbang: false,
history: true,
linkActiveClass: "active",
root: 'manage'
}
);
router.mode ='html5';
router.map({
'/login':{
component: require('./be-views/login.vue'),
auth:false
},
'/register': {
component: require('./be-views/register.vue'),
auth:false
},
'/logout': {
component: require('./be-views/logout.vue'),
auth: true
},
'/index': {
component: require('./be-views/index.vue'),
auth: true,
subRoutes: {
'/': {
component: require('./be-views/home.vue'),
auth: true
}
}
},
'*': {
component: require('./be-views/404.vue')
}
});
router.alias({
'/':'/index'
});
Vue.use(require('vue-jwt-auth'),
{ fetchUrl:'/api/me',
loginUrl: '/api/login',
notFoundRedirect: '/index',
tokenUrl: '/api/refresh'}, router);
router.start(App,'body');