I got this on Routes, set a localStorage key to know if the user can enter the page (turnos.html), if not navigate to another page (turnodado.html).
routes: [
...
{
path: '/turnos/',
url: 'turnos.html',
name: 'turnos',
beforeEnter: function (routeTo, routeFrom, resolve, reject) {
if (localStorage.getItem('turno') === null) {
console.log('antes1');
resolve({ url: 'turnodado.html' });
} else {
// don't allow to visit this page for unauthenticated users
console.log('volver');
resolve({ url: 'turnos.html' })
}
},
options: {
transition: 'f7-parallax',
},
},
],
On the console I see the console.log(‘antes1’) that I added to check if it works, but always show me the page turnos.html. Enter to the page turnodado.html, but then shows turnos.html.
At the moment I don’t set anything to localStorage so the if statement is true, just to check if it’s works.
What i’m doing wrong.