I have the following route definition.
export const Routes = RouterModule.forChild([
{
path: 'login',
component: LoginComponent
},
{
path: 'protected',
canActivate: [AuthGuardService],
component: ProtectedComponent
},
{
path: 'home',
component: HomeComponent,
canActivate: [AuthGuardService],
},
]);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With