Remove the login menu? (AngularJS and UI router)

0

Good afternoon,

I'm participating in a project and I'm using AngularJS and UI-router, much of it already done, but I'm not sure how I can get the login menu, I'd like it to appear only after authentication. If anyone can give a force there, thank you right away. Below is the print and the routes.

Routes:

const boletoCorretoraState = {
  name: 'boletoCorretora',
  url: '/boletoCorretoraPublico',
  component: 'boletoCorretora',
};

const boletoEstoqueState = {
  name: 'boletoEstoque',
  url: '/boletoEstoquePublico',
  component: 'boletoEstoque',
};

const consolidadoState = {
  name: 'consolidado',
  url: '/consolidado',
  component: 'consolidado',
};

const consultaState = {
  name: 'consulta',
  url: '/consulta',
  component: 'consulta',
};

const loginState = {
  name: 'login',
  url: '/login',
  component: 'login',
};

$stateProvider.state(boletoCorretoraState);
$stateProvider.state(boletoCorretora2State);
$stateProvider.state(boletoEstoqueState);
$stateProvider.state(boletoEstoque2State);
$stateProvider.state(consolidadoState);
$stateProvider.state(consultaState);
$stateProvider.state(loginState);

$urlRouterProvider.otherwise('/login');
$locationProvider.html5Mode(true);

}

    
asked by anonymous 30.01.2018 / 19:05

1 answer

0

Guilherme, in your case I believe you would have to nest the states that need a logged in user ( Example of nested states ) and in your menu directive use $ state.is to check if the current state is no longer logged in.

You can still check your service / cache to see if there is an authenticated user and avoid the above suggestion.

    
31.01.2018 / 00:54