Questions tagged [angular-router-guards]

To find more information :

289 questions
0
votes
2 answers

How can i return result from subsribe method on with observable pattern

I have getNewToken and hasTheUserTokenOrPermission methods. The first one returns token and set the user data after that the second one checks after WE SET THAT user data - if he has permission to see something in the guards. So i need to wait for…
sdsd
  • 447
  • 3
  • 20
0
votes
1 answer

CanDeactivate Not Firing in iFrame

I have an application which has an iframe into a separate Angular application. The src of the iframe is to a component. Long story short, the Angular app has to redirect to the home page, then back to the component in the src. If I use my back…
ScubaSteve
  • 7,724
  • 8
  • 52
  • 65
0
votes
1 answer

Stop Mat Dialog from appearing based on condition

I would like for a Mat Dialog to not appear if a specific condition has not been met. I had hoped to use Angular Guard, but there seems to not be an associated route with the component (aside of the overarching webpage it's called…
d-cubed
  • 1,034
  • 5
  • 30
  • 58
0
votes
1 answer

How to unit test Resolve and CanActivate

I want to unit test the following guard resolve(): Observable < Game > { return this.gameRoom$.pipe( tap(data => { this.gameService.updateGame(data); })); } canActivate( next: ActivatedRouteSnapshot, state:…
0
votes
1 answer

Angular guard CanLoad triggers only once upon first lazy load

I've got a simple guard on my admin area { path: 'admin', canLoad: [AuthGuard, AccountGuard], loadChildren: () => import('./features/admin/admin.module').then((m) => m.AdminModule), data: { preload: false } }, It works nice…
user3887366
  • 2,226
  • 4
  • 28
  • 41
0
votes
1 answer

Angular guard and browser back button: weird interaction

I have a home page and two subpages. I'm guarding user navigating away from subpage1 using Angular guards. I followed the guidelines here, and I added some logic to separately handle clicking on a link and using the browser back button. I reproduced…
0
votes
1 answer

Handle multiple Observables for Angular Router Guard

I'm new to RxJS but seems to fit my needs. I am wondering if it's possible to retrieve an Observable that listen two BehaviorSubject. First I use Angular 10 ! I am using a service called on my components that call on create a promise to retrieve…
Thibaud Renaux
  • 280
  • 1
  • 17
0
votes
1 answer

How to pass a boolean parameter from Route Guards in Angular

I need to guard the routerLinks based on some boolean configurations coming from a server. Currently i have written canActivate route guard. ActivateRoutes file async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):…
0
votes
1 answer

Which Guard fired GuardsCheckEnd?

We have a few router guards that protect different parts of our app. In some cases, but not in all, we want to do things when the guard returns false. router.events.subscribe(event => { if (event instanceof GuardsCheckEnd){ if…
AvailableName
  • 666
  • 4
  • 13
  • 24
0
votes
2 answers

how can I get the value of a promise to do the validation on the canActivate?

I need to get the value that returns this.isJwtValid() but currently it is not returning the value of the result of the promise, the code continues its flow without stopping there, and I need to get the result of this promise in this line: let token…
yavg
  • 2,761
  • 7
  • 45
  • 115
0
votes
1 answer

Angular OAuth2 Check for Privileges in Guard

In my app, I need to only allow users with certain privileges to view certain "pages". I thought the best way to do this was to create a PrivilegeGuard. I currently have an AuthGuard (I'm utilizing…
ScubaSteve
  • 7,724
  • 8
  • 52
  • 65
0
votes
1 answer

How to get user and cart data in authentication guard on refresh?

I am having problem with CheckoutAuthGuard on spartacus storefront. When browser refresh button is pressed on any page in checkout process, guard redirects me to a login due to missing user and cart info. I have used CustomCheckoutAuthGuard like…
0
votes
0 answers

Angular Route url update

I am working on a enhancement in my project. Requirement : If user manually update the url, it should set back to present url. for example: Intial…
Adithya
  • 183
  • 1
  • 2
  • 16
0
votes
0 answers

Angular 7 : Clean url parameters on canActivate

Its possible to clean url parameters during canActivate? routing: const routes: Routes = [ { path: 'myRoute', component: MyRouteComponent, canActivate: [MyGuard] } ] guard: canActivate(route: ActivatedRouteSnapshot, state:…
antia
  • 83
  • 2
  • 13
0
votes
1 answer

angular guard with angular-redux/store

I'm using @angular-redux/store in my project. I'm trying to create a guard with @select() decorator like this: @select((s: IAppState) => s.user.userInformations.userState) userState$: Observable; and my canActivate method is like this…