Questions tagged [canactivate]

145 questions
2
votes
1 answer

get parent route params inside canActivate

I've routes like this: [ { path: ':orgName', children: [ { path: '', component: HomeComponent canActivate: [AuthGuard], }, { path: 'details', component: DetailComponent } …
Drunken Daddy
  • 7,326
  • 14
  • 70
  • 104
2
votes
1 answer

CanActivate in Angular 2 return undefined

I need that canActivate do not skip further until json loads, for this I put a check if canActivate is not undefined, it returned false, but in the console it outputs that canActivate is passed and with the value undefined. What I'm doing is wrong,…
Vonny
  • 39
  • 3
2
votes
1 answer

canActivate returning Promise or Observable blocks Change detection

When I add canActivate that returns either an Observable or Promise (in this case a promise) the routing works correctly but it seems to block things like (click) events, pipes don't work correctly, etc... These functions all work as soon as I make…
2
votes
1 answer

Multiple Guards calling async function

I have two Guards, Guard1 and Guard2. Guard1 returns an Observable and Guard2 returns Boolean. canActivate: [Guard1, Guard2] Assuming that Guard2 will return false, is the request from Guard1 automatically cancelled? or the call will be executed…
2
votes
2 answers

Uncaught (in promise): Response with status: 401 Unauthorized for URL

I am trying to implement authGuard for my Routers. but when I interfere with error codes, the app breaks actually. I don't know how to tackle it. assistance needed. My AuthGuard canActivate(route: ActivatedRouteSnapshot, state:…
Sibiraj
  • 4,486
  • 7
  • 33
  • 57
2
votes
0 answers

Argument of type 'ActivatedRoute' is not assignable to parameter of type 'ActivatedRoute'

I am getting an error of Argument of type 'ActivatedRoute' is not assignable to parameter of type 'ActivatedRoute'. Types of property 'url' are incompatible. Type 'Observable' is not assignable to type 'Observable'. Two different types with this…
Ishan Malik
  • 139
  • 3
  • 12
2
votes
1 answer

Angular 2 navigate to root from CanActivate service

HI I have strange issue and don't understand how to fix that. So I have service that check if you logged in when go to some url in web app. If not it redirect to home page. My service` import { Injectable } from '@angular/core'; import {…
Aram Mkrtchyan
  • 2,690
  • 4
  • 31
  • 47
1
vote
1 answer

Angular : Routes access restrictions for Logged users

I Need to restrict the logged in user from accessing all the routes when the user is forced to change password after its expiry. The user should not be able to manipulate the URL in the address bar once he is redirected to the change-password…
RandomSync
  • 11
  • 1
1
vote
0 answers

Auth guards for google oauth2 connection always returns false

I'm on a angular project using angular-oauth2-oidc. There is login component, a home component and a auth guard that enable to go to /home only if I'am connected. The connection is with google sign in oauth2. When I try to use canActivate on the…
Lucas
  • 11
  • 1
1
vote
1 answer

Invalid configuration of route '': redirectTo and canActivate cannot be used together

I want to do laravel angular jwt authentication, so I want to apply guard but it gives me error: Invalid configuration of route '': redirectTo and canActivate cannot be used together. Redirects happen before activation so canActivate will never be…
achraf bourki
  • 159
  • 2
  • 11
1
vote
1 answer

How to evaluate multiple observables in canActive guard?

I have this guard that is evaluating multiples observables, but in the verifyMoviesStore observable is having issues, this is a selector from NgRx, the problem with this one, is that is updating the data serveral times, this gap of time, is causing…
Tabares
  • 4,083
  • 5
  • 40
  • 47
1
vote
0 answers

lazy loading with CanActive

I implemented lazy loading in my project and it works well: the components load only if the http route is requested. but when I implement canActive to prevent some users from accessing: the user can no longer access but Lazy loading still loads…
tshishi
  • 11
  • 2
1
vote
2 answers

Angular CanActivate guard wait for api response and not calling api everytime

I have an observable to check if the user is loggedIn or not. I set that observable from auth api which is called from appComponent when application starts. export class AppComponent implements OnInit { loggedIn$: Observable
Bhavesh
  • 819
  • 1
  • 17
  • 31
1
vote
1 answer

How to call an async method in canActivate | Ionic ,Angular

I want to get a token to authenticate the users. I save the data with import { Storage } from '@ionic/storage-angular'; the problem is that Storage methods just works in async mode. This is the storage service import { Injectable } from…
pupy frias
  • 109
  • 3
  • 9
1
vote
1 answer

How can i use canActivate() to block access to certain routes?

I am actually working on an website that have multiple users. I want to update a user's information and it works so fine but when i type on the URL an id of another user instead of the current user i can simply access to that profile while i am not…
1 2
3
9 10