Hello everybody, i’m just testing F7 Vue implementation. I downloaded this starter template: https://github.com/framework7io/framework7-template-vue-webpack
And I want to check if user is logged in, I used the following code:
import HomePage from './pages/home.vue';
import NotFoundPage from './pages/not-found.vue';
import Login from './pages/login.vue';
import PanelLeftPage from './pages/panel-left.vue';
function checkAuth(to, from, resolve, reject) {
if (localStorage.getItem("token")) {
resolve();
} else {
resolve({
component: Login
});
}
}
export default [{
path: '/',
component: HomePage,
beforeEnter: checkAuth
},
{
path: '/login/',
component: Login,
},
{
path: '/panel-left/',
component: PanelLeftPage,
},
{
path: '(.*)',
component: NotFoundPage,
beforeEnter: checkAuth
},
];
As you can see, on beforeEnter i’m calling “checkAuth” function. The problem is when I call this resolve({component: Login});
it redirects to ‘/’ path, and not to Login component. It is like “resolve” function is not getting my params.
What am I doing wrong?
Thank you for your time.