[Solved]Authentication Rote

Hi,
I need a authentication structure. I’ll use an api for this. I will keep incoming information in localstorage. If the information is missing, I want to redirect to the login page. I did some research for this and found a code like this. But it doesn’t work. A blank sheet is coming. No errors are coming

var routes = [
  {
    path: '/',
    beforeEnter: 	function(routeTo, routeFrom, resolve, reject){
      if(isLogged == "true") {
        resolve({
          component: HomePage
        });
      } else {
        resolve({
          component: Login
        });
      }
    }
  }
];

I solved. ‘beforeEnter’ change ‘async’.

var routes = [
  {
    path: '/',
    async: 	function(routeTo, routeFrom, resolve, reject){
      if(isLogged == "true") {
        resolve({
          component: HomePage
        });
      } else {
        resolve({
          component: Login
        });
      }
    }
  }
];
1 Like