Hi,
Templates have a behavior of showing the dashboard page for a fraction of a second, even when the user is not logged in. When accessing the app made with the template, it shows the dashboard screen for a fraction of a second and then the user is redirected to the login page, causing a bad experience.
Is this behavior possible to change?
I don't want to show the inside of the system to a user who is not registered.
Thanks!
MB
PS. Using VUE in 8.1.5 Metronic version
Hi Mateus,
Do you use the same redirect functionality as it is in the latest Metronic?
We redirect unauthenticated users to the sign-in page and dashboard page shouldn't appear.
Check router/index.ts.
if (to.meta.middleware == "auth") {
if (store.getters.isUserAuthenticated) {
next();
} else {
next({ name: "sign-in" });
}
} else {
next();
}
Hi Lauris,
Implement the code, but even so the behavior remains the same, ie it didn't work.
Any other idea?
BR,
MB
This code shouldn't allow the unauthenticated user to see the dashboard page.
Were you able to reproduce this issue on our preview page?
https://preview.keenthemes.com/metronic8/vue/demo1/#/dashboard
As an alternative solution, you can use v-if
directive in src/layouts/main-layout/MainLayout.vue.
Add new computed property:
const isUserAuthenticated = computed(() => {
return store.getters.isAuthenticated();
});
<div
v-if="isUserAuthenticated"
class="d-flex flex-column flex-root app-root"
>
</div>