Questions tagged [canactivate]

No instructions have been provided for implementing this tag at the moment!

Getting the value from an Observable in Angular 2 after using the CanActivate guard and subscribing

I am using a "CanActivate" method in my web service to check if the user is logged in. The "CanActivate" method returns an Observable. My main concern is how to retrieve this boolean value so that I can adjust my view based on whether the user is connecte ...

Having difficulty implementing canDeactivate or canActivate in Angular

I am currently trying to integrate the canDeActivate and canActivate functions in my Angular 4 project. However, I seem to be encountering a no provider error. Can someone please guide me on what might be wrong with my implementation or suggest a cleaner a ...

The CanLoad guard does not permit access to the root route

My original idea was to create a project where the main website, located at "/", would only be loaded lazily after the user logs in. const routes: Routes = [ { path: '', canLoad: [AuthGuard], loadChildren: './home/home.module#HomeModule' }, { path: 'l ...

Angular2: AuthGuard malfunctioning with browser navigation controls

My AuthGuard setup works flawlessly during normal navigation within the application (see code below). Now, consider this scenario: A user goes to /content/secured-content, which requires authentication => they are redirected to /authentication/login due ...