I am not an interface developer, but I know enough javascript to make a minimum.
I am trying to connect to the last part of the login, but my components are vue:
"vue-resource": "^0.9.3", "vue-router": "^0.7.13"
I'm not experienced enough to upgrade to v1 or v2 respectively. I would like to achieve something similar to this .
However, I am not getting a successful redirect.
my app.js file:
var router = new VueRouter(); ... import Auth from './services/auth.js'; router.beforeEach(transition => { if(transition.to.auth &&!Auth.authenticated) { transition.redirect('/login'); } else { transition.next(); } }); ``` In my login.js file ``` methods: { login(e) { e.preventDefault(); this.form.startProcessing(); var vm = this; this.$http.post('/api/authenticate', { email : this.form.email, password : this.form.password }) .then(function(response){ vm.form.finishProcessing(); localStorage.setItem('token', response.data.token); vm.$dispatch('authenticateUser'); }, function(response) { if(response.status == 401) { let error = {'password': ['Email/Password do not match']}; vm.form.setErrors(error); }else{ vm.form.setErrors(response.data); } }); } }
I tried to do as suggested:
vm.form.finishProcessing(); localStorage.setItem('token', response.data.token); vm.$dispatch('authenticateUser'); vm.$route.router.go('/dashboard');
However, all he did was add the url on top. I see that the 3 previous events were successful, but not redirected.
this happened: http://dev.homestead.app:8000/login#!/ at http://dev.homestead.app:8000/login#!/dashboard
when i need the whole page to go to: http://dev.homestead.app:8000/login/dashboard#1/
I think I have a missing concept to redirect correctly.
UPDATE
As suggested, I added param: append => false , but nothing happens.
what I did after that was in app.js, create the redirectLogin () method with the console.log () outputs - which worked. what I did next, I put vm.$route.router.go and called the method through vm.$dispatch('redirectLogin'); , and that didn't work either.
Note
HTML is first created in Laravel. the route that I originally had (and worked) as a login / dashboard, and this route is accessible through the usual Laravel route. the blade is rendered using a presentation template.
While I'm trying to redirect redirection to login / dashboard (doesn't work), maybe I need to somehow remove login/dashboard and use route.map and assign login/dashboard ?
I would rather keep login/dashboard as a laravel route due to authentication and other manipulations.