vue-firebase-auth-vuex
vue-firebase-auth-vuex copied to clipboard
Cannot reach Routes with AuthGuard
First I want to thank you for this good starting point!
I have a problem with the routing system here, as I cannot reach /profile or /dashboard (whatever restricted route given), as it redirects me always to the "/" home page.
I do not want to have a seperate /signup and /signIn page, so I store them in a dialog and the login and signup itself works fine and as expected.
Somehow, within the auth-guard.js I set in the else condition next('/') instead next('/signup') (as I dont want to have this extra route)
Is this maybe causing the problem? I did not make any other changes to your code, besides this one.
If you need further information, please contact me.
Here is my router index.js and auth-guard.js
import Vue from 'vue'
import Router from 'vue-router'
import AuthGuard from './auth-guard'
const Home = () => import('@/components/Home')
const Profile = () => import('@/components/User/Profile')
const Dashboard = () => import('@/components/Dashboard/Layout')
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/dashboard',
name: 'Dashboard',
component: Dashboard,
beforeEnter: AuthGuard
},
{
path: '/profile',
name: 'Profile',
component: Profile,
beforeEnter: AuthGuard,
children: [
{
path: '/settings',
name: 'Settings',
component: () => import('@/components/User/Settings')
}
]
}
],
mode: 'history'
})
and the auth-guard.js
import {store} from '../store'
export default (to, from, next) => {
if (store.getters.user) {
next()
} else {
next('/')
}
}