Questions tagged [angular-route-guards]

89 questions
0
votes
1 answer

Why my object become empty when I reach a specific route?

I have a problem. So, I want to create a route guard in Angular that doesn't allow the user to reach login page if he is logged in. I check if he is logged in if the BehaviourSubject from the AuthService emits a new user object, but when I type in…
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
0 answers

Angular child routes (lazy loaded into AppRoutingModule) data is always an empty object ({}). Trying to access it from route guard

I've been struggling with this issue for a week or so but everything I've found online (and tried) is not helping. I have an AngularJS project (Angular v11) with the following structure: src/app ├── app.component.ts ├── app.module.ts ├──…
0
votes
2 answers

Angular canActivate execute ahead of time

I have setup my routes and route guards in Angular and they are working great for stopping the user from accessing a route that they shouldn't. However, I have a global navigation section on all my pages and it basically loops over my array of…
Scott Dietrich
  • 686
  • 1
  • 8
  • 20
0
votes
1 answer

Redirect to Authorization Endpoint at First Load Angular

I am trying to find a solution that will redirect to the authorization endpoint before loading the angular first (html and components). Is that even possible? Or is it possible to use CanActivate auth guard on my main app.component? I am using an…
interkey
  • 355
  • 5
  • 21
0
votes
1 answer

Show initial user setup component only on first login

I have 2 components intial-settings and app-navbar inside my app.component.html: And my app.component.ts: export class AppComponent { public…
hawran
  • 131
  • 3
  • 11
0
votes
1 answer

Is CanLoad guard usable within Electron application?

I have permission DTO coming from BE which determines parts of application accessible to the user. Using NgRx selector I want to use it inside the CanLoad guard but I can't get it to work. routes.ts { path: 'acquisition', canLoad:…
mat.hudak
  • 2,803
  • 2
  • 24
  • 39
0
votes
1 answer

Angular Service for Kendo Dialog throws an error

I need to trigger a dialog through the CanDeactivate routeguard, if the user tries to navigate out of a page without saving the form. I'm following the solution suggested here. I want to customize the confirm dialog used in the example, using the…
devC
  • 1,384
  • 5
  • 32
  • 56
0
votes
0 answers

waiting properly for multiple observables to return data in a route guard before canActivateChild returns true/false

I am having an issue with my canActivateChild route guard not waiting for data to come back from 3 service calls to the backend before determining whether it can activate the route or not. I have it hooked into the ngRx store and am dispatching 3…
MattE
  • 1,044
  • 1
  • 14
  • 34
0
votes
2 answers

How can I allow routes to users based on module condition?

I know the usage of Auth guard in Angular and I am just a beginner in angular I just made a basic authentication based on read write access that includes roles like isAdmin or Isguest But now I want that particular user must be able to access only…
0
votes
1 answer

How to determine route prior to route guard Angular?

so I have lets say 2 routes '/admin-route' and '/superuser-route' and both require 'admin' and 'superuser' privileges respectively to access these routes. When user clicks on this route I check privileges and if they're false for that user I…
Adi
  • 9
  • 7
0
votes
2 answers

Angular Route Guard based on collection query result

I have a 'Teams' collection in Firestore. A team document will include a team_users map field where userID: true if they are a part of that team. I have a query in a service that returns and displays all team documents where the logged in user id…
Haven
  • 87
  • 1
  • 9
0
votes
3 answers

Angular Method not saving value of variable

I am creating a Route Guard in Angular; how it works is depending on if you are associated with a company; it will send you to a particular component. Unfourtnetly when running canLoad method, it does not save the value of the companieslist…
user12644181
0
votes
1 answer

Login fails for the first time login and refreshing page forces user to logout in Angular+(Node/express).js

When I first try to login it does authenticate the user and set the loggedInStatus in AuthService as true but the loggedIn in the AuthGuard is set false and thus does not allow to navigate to the dashboard.. also the sequence of console.logs is out…
user10062908
0
votes
0 answers

Unable to route to same/current page in angular using route guard with setTimeout()

I am unable to route to same page and I am not sure what is missing here. If I remove the setTimeout function it is working fine, but not working with setTimeout. Is there any way I could delay the routing? { path: 'sample-page', component:…
Murali
  • 49
  • 9