Created
April 9, 2016 13:36
-
-
Save leosilvadev/e9ad9fd62e4211cb803837d72e03cb35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('blogjs.post').run(function($rootScope, $location){ | |
var paginasLivres = [ | |
'/posts', | |
'/usuario/cadastro', | |
'/login' | |
]; | |
$rootScope.$on("$locationChangeStart",function(event, next, current){ | |
var path = next.split('/#')[1]; | |
var encontraPagina = function(pagina){ | |
return pagina === path; | |
} | |
if ( !paginasLivres.find(encontraPagina) ) { | |
var usuarioLogado = localStorage.getItem('usuarioLogado'); | |
if(!usuarioLogado){ | |
$location.path('/login'); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment