Questions tagged [angular-guards]
123 questions
0
votes
1 answer
How to fetch logged in use details before initializing the application using JWT token from Cookies
I have an angular application where I am generating JWT token using SSO login. Now, I want to fetch logged-in user details before initializing the application and store the data on run time.
I also want to use user data in Route guards to validate…

ayush sachdeva
- 1
- 2
0
votes
0 answers
I am selecting CanDeactivate option even though created CanActivate guard in angular CLI
I am trying to create CanDeactivate guard by using angular CLI but it is creating CanActivate guard even though choosed correct option.
0
votes
2 answers
Angular guard true/false depending on permission
I have 4 routes where each one will have a permission linked to it (provided by the backend -> true/false). These permissions give a logged-in user the authorization to access particular routes.
Now my question is if it is possible to make only one…

Lorenzo
- 185
- 2
- 4
- 16
0
votes
1 answer
Angular Routing to Child path based on role
After successful login, I redirect to following path
this.router.navigate(['/main/'])
Based on role received from login. Is it possible to redirect to diff modules.
Example: If Role is 'Admin' if I redirect to ['/main'] based on role it will…

raviguggilam
- 17
- 6
0
votes
1 answer
Failed to export .guard to another lib Angular
im trying to use a Router Guard from shared lib into app routing module (at app level).
i created this RouterGuard (route.guard.ts):
@Injectable({
providedIn: 'root'
})
export class RouteGuard implements CanActivate {
constructor(private…

Flávio Costa
- 895
- 5
- 18
- 41
0
votes
1 answer
How can I prevent canActivate from executing before a ReplaySubject finished in the constructor of the Angular guard?
I have a guard with a constructor similar to the snippet below.
//Constructor of my guard.ts file
constructor(
private helperService: HelperService
) {
this.helperService.replaySubjectProperty.subscribe(val => {
this.helperValue =…

RLH
- 15,230
- 22
- 98
- 182
0
votes
1 answer
How can i make my guard to wait for http call in resolver?
I have resolver and guard.On my base route path i have resolver which makes http call - to get token for authentication.
Inside child routes i have guards for permission.
Always guard is executed before the resolver - so the problem is that first my…

sdsd
- 447
- 3
- 20
0
votes
1 answer
make delay in canActivate till IP address data is fetched
I'm making a guard for my angular application where all users should be redirected to maintenance page except for certain IPs. I'm getting the client IP address using third party APIs like http://api.ipify.org/?format=json. The PROBLEM I'm facing is…

surjendu_dey
- 578
- 2
- 11
- 28
0
votes
2 answers
Subscribing to behaviour subject, modifying data & setting value again resulting in infinite loop
We have a wizard functionality, wherein we have a lazy loaded module having a parent component & multiple child components.
const routes: Routes = [
{
path : '',
component : WizardHomeComponent,
canActivate: [HomeGuard],
children…

rajit
- 154
- 1
- 3
- 12
0
votes
1 answer
Can Angular Guard or Firebase Auth be easily hacked
I read that since Angular is client based it can't be trusted alone for securing routes, etc. However, I could not find a way to hack it.
Can anyone explain in detail how one might edit the local js files to bypass route guard (or whatever method…

Ben
- 495
- 1
- 7
- 17
0
votes
1 answer
How to get a generic component property that has been passed into my canDeactivate Guard in Angular?
I want to pass multiple components (Component1 | Component2) into my canDeactivate guard, so I'm using generics like this below.
Problem - There is a property I want to access from each of the components I pass in, so how do get the generic…

chuckd
- 13,460
- 29
- 152
- 331
0
votes
2 answers
CanActivate guard in angular routing without repeating "CanActivate " property
I want to use the canActivate guard in routing without repeating the
canActivate: [AuthGuard],
code like below
import { AuthGuard } from 'src/app/core/guards/auth.guard';
const routes: Routes = [{
path: '', data: { title: 'Users' },
…

Piumi ganegoda
- 163
- 3
- 12
0
votes
1 answer
Check if user is null in Angular Guard
I have an Angular pipe which checks if a user is a premium member before navigate to specific routes.
Premium Guard:
return this.afAuth.authState.pipe(
take(1),
switchMap(user => {
return this.db.getUserWithKey(user.uid)
}),
…

Vueer
- 1,432
- 3
- 21
- 57
0
votes
1 answer
How do I get an Angular Guard to use an API service for verifcation and reroute on failure?
Good day!
I have an Angular 7 application for working with time cards. I am using a CanActivate Guard on being able to enter a component. The CanActivate code uses an Observable to determine if they should be let through or redirected.
…

Avogadro
- 353
- 2
- 11
0
votes
1 answer
Angular router guard with Observable does not work after page refresh
I have the next Angular Guard:
export class AdminGuard implements CanActivate {
constructor(
private readonly router: Router,
private readonly userService: UserService
) { }
canActivate(
next: ActivatedRouteSnapshot,
state:…

Volodymyr Humeniuk
- 3,411
- 9
- 35
- 70