Hi guys, I am trying to set up routing with authentication properly.--So far I am using the router's canActivate decorator to determine if that component can be shown or not. The question is: where do I put the redirect to a login page? Doing a hard redirect with window.location within the canActivate check seems to be wrong). Should I override the router-outlet instead, and if so, how?
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
this.router.subscribe((nextValue) => {
if (nextValue !== 'login' && nextValue !== 'register' && !this.sessionService.accessToken()) {
this.sessionService.data['urlRedirectAfterLogin'] = nextValue;
this.router.navigate(['/Login']);
}
});