I am trying to check if a user is authorized and if not direct him/her to login page. I actually managed to do that but i am having an hard time how the mechanism works. please see below code.
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
let fus: FakeUserService = new FakeUserService();
if(!fus.authorization()){
this.router.navigate(['login']);
return false; // Code works even this line is commented out. The user is redirected to the login page.
}
return true;
}
The point i don`t understand is how router.navigate works in this scenario. Does user go to the intended page and navigated back to login when i comment out "return false"?. Or "router.navigate" function overrides all the routing commands? I am kind of confused..