In my $ stateProvider I have defined the views of my application in which certain views require that the user is logged in or not. So far, he is working correctly. But the problem I have now is that I have a view which the user must access with or without login, this is my code:
.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state('registro',{
url:'/registro',
templateUrl:'app/carpeta1/vista1.html',
controller: 'registroCtrl',
authenticate: true
})
.state('registro_emp',{
url:'/registro_emp',
templateUrl:'app/carpeta2/vista2.html',
controller: 'registro_empCtrl',
authenticate: false
})
.state('empresas', {
url:'/empresas/:id_empresa',
templateUrl:'app/carpeta3/vista3.html',
controller: 'perfilEmpCtrl_sl',
authenticate: true/false (aqui deseo llamar a una factoria la cual me devuelve si el usario esta o no logueado)
})
$urlRouterProvider.otherwise('/login');
})
this is my factory:
.factory("Autenticacion", function($cookies, $cookieStore)
{
return{
isAuthenticated : function()
{
var username = $cookieStore.get('username');
if(typeof(username) != "undefined")
{
return true;
}else{
return false;
}
}
}
})
My question is how to insert the factory that returns my login status in the state "companies" > since that view can be accessed by the user with login or without login
Thank you in advance