Questions tagged [angular-guards]
123 questions
1
vote
2 answers
In page refresh: ngrx store dispatch issue with guard canactivate
i don't have an login page , this is sso call
In the app component, I have dispatched an action to load the server-side token call and get the token and based on the user roles I can activate the guard in routing. if guard activates return true, I…

Mohamed Sahir
- 2,482
- 8
- 40
- 71
1
vote
1 answer
Angular - Cannot get current user's role in guard to check if the he/she has permission to access protected routes
I am trying to implement role based access control on Angular based project where there are multiple types of roles
I want to get user's data(role property) in CanActivate interface to check if the user has permission to access protected routes in…

johannesMatevosyan
- 1,974
- 2
- 30
- 40
1
vote
1 answer
How to check: is the User logged in with angular-6-social-login npm package?
I have successfully integrated with angular-6-social-login (https://www.npmjs.com/package/angular-6-social-login) to login into my angular APP using google account.
I am creating an Angular Guard to protect the routes so that only users can access…

javapedia.net
- 2,531
- 4
- 25
- 50
1
vote
1 answer
Angular Guards lifecycle clarification
I was trying to find any information on the lifecycle application initialization.
There are few types of guards. I'm interested in following types:
CanActivate
CanLoad
CanActivateChild
Suppose we have following route configuration:
{
path:…

Maxian Nicu
- 2,166
- 3
- 17
- 31
1
vote
2 answers
Navigation from Angular Guard not working when using Observables
I've run into an interesting issue where my Angular Guard doesn't seem to do anything when I try to redirect in cases where the user is trying to access routes that they shouldn't be.
As you can see, I've placed console.log calls throughout the…

Olly John
- 366
- 5
- 20
1
vote
3 answers
How to guard route if HTTP GET request returns no data?
Below is a table in my Angular app. It is populated with data from employees.json:
{{employee.fullName}}
…

user9847788
- 2,135
- 5
- 31
- 79
1
vote
1 answer
Angular - Are admin files downloadable?
I have a website with Angular. I implemented the auth with jwt. I know we can prevent the user to go to the restricted routes with Angular Route Guard.
Usually in SPAs all routes (html) are downloadable. Just we handle unauthorized routes in server…

Vahid Najafi
- 4,654
- 11
- 43
- 88
1
vote
1 answer
Different RoleGuard in a Child Item Angular Routing
I wanted to know if you use a RoleGuard to check if someone can activate the path and you want a different RoleGuard in a child item could be possible:
I already tried but I can't acces to the path with the different RoleGuard
{
path: 'admin',
…

Gonzalo
- 309
- 2
- 6
- 18
1
vote
2 answers
CanActivateChild not running
I have a problem that when I logout and navigate to /, canActivateChild guards are not executed to redirect to login.
My requirement is that none of the app is accessible without login.
Here is my root Route config:
const appRoutes: Routes = [
{
…

f.khantsis
- 3,256
- 5
- 50
- 67
1
vote
1 answer
Angular 7 - mat-select input doesn't open sometimes when use guards
I'm starting with multiple applications structure in Angular and I found weird behavior on mat-select from Angular Material...
I can't open dropdown - overlay is not appeared and normal click event is dispatched instead of material open with…

Wojciech Parys
- 339
- 2
- 18
1
vote
1 answer
Angular 6 How to implement canActivateChild
I'm new to Angular auth guard. I have successfully integrated auth guard so that logged in users can access the private pages. For this, I used CanActivate. Now, my intention is to use another type of guard which prevent the logged in users to…

Niladri Banerjee - Uttarpara
- 2,219
- 8
- 52
- 92
1
vote
2 answers
Angular guard with multiple conditions and redirects
I want to create a complex router guard that checks if the user is authenticated in the web application but, if so, it checks also other condition and for each true condition it redirects to a page (that is however under the same router guard). For…

bertonc96
- 772
- 2
- 13
- 24
1
vote
2 answers
Close side menu on back click
Im building an Angular application and having some troubles with closing the menu on popstate.
when the side menu is open and the user clicked on the back button on his mobile device i want the menu to close the menu, for that im using pop state…

Matan Shushan
- 1,204
- 1
- 10
- 25
1
vote
3 answers
How to redirect to login page if the user is not logged in?
I have implemented the before login and after login guard so that some users can not access all the pages. My question is when user is not logged in & when they try to enter the unauthorized page such as "localhost:4200/restricted_page" it should be…

user1687891
- 794
- 2
- 14
- 30
1
vote
2 answers
Dynamically register canDeactivate guard and prompt to confirm navigation
Is there any way a component can dynamically register the canDeactivate guard for itself?
Its mainly to prompt/stop the user from navigating with confirmation like Yes/No.
I'm trying to do this because the application in question is quite large and…

ashish.gd
- 1,713
- 1
- 14
- 25