I have successfully implement AuthGuardService which restrict access to a protected route if user is not logged in.
What I am trying to achieve is, if user is already logged in and accessed the Login Route, I want it to redirect to another route like homepage.
You could perform a simple check in the ngOnInit of the login component like so and redirect to another page of your choice if they are authenticated already:
ngOnInit() {
if (this._authService.isLoggedIn) {
this._router.navigate(['/apps']);
}
}
That worked for me!