I have seen multiple people posting in regards to similar (if not the same issue) but none of the solutions work for me.
I have a standard auth gateway using a local strategy (email, password) and I want to redirect to root (or their dedicated page) on successful auth.
It should be as simple as this.$router.push('/')
or this.$router.push(user)
but nothing happens at all. This is the code...
async initialise({ commit, state}) {
this.$toast.info('Initialising...');
try {
const { data } = await this.$axios.get(`/initialise/${state.auth.user.shop}`);
commit('INITIALISE_SHOP', data.shop);
commit('employees/SET_EMPLOYEES', data.employees, { root: true })
this.$toast.success('Login Successful');
this.$router.push('/'); <<< this is the offending line
} catch (error) {
this.$toast.error('Unable to fetch schedule data. Please contact the Support Team.');
}
}
What's even more weird is if I get rid of ALL the code and just put the router function in it will just not do anything at all.
Let me add to this...
If I add console.log()
into the code ANYWHERE it will log. I can put it before the http request, I can put it before the $toast
or I can put it AFTER the unsuccessful this.$router.push('')
and it will log whatever I'm putting in.