Questions tagged [canactivate]

145 questions
0
votes
0 answers

Git bash activate error that still remains even after using clear and cls

I used the activate command on gitbash and found an error and now the error appears anytime I open gitbash. I have tried clear and even resetting to no avail I tried using clear and cls to erase the error completely but it hasnt worked yet
0
votes
0 answers

Router parseUrl() vs navigate() in Angular16

I am in Authenticate with authGuard. I would like to know the difference between these two // Redirect to the login page return router.navigate(['/login']); return router.parseUrl('/login'); In Angular official documentation it is showing…
0
votes
2 answers

How to get dynamic parameter in functional canActivate guard without ActivatedRoute in Angular v16?

I'm trying to implement a functional canActivate guard in Angular v16, but I'm facing an issue with retrieving dynamic route parameters. I want to access the username and id parameters from the route in my guard function, but when I try to retrieve…
0
votes
1 answer

Angular CanActivate Guard

I am developing a small project using Angular, Nodejs, Express, MySQL. In the project there is 2 type of user, customer user and contractor user. I am having difficulty in using CanActivate to guard the route for the 'Contractor Profile Page' and…
0
votes
1 answer

Return boolean observable on angular guard

I would like to block URL access from unauthorized users. I'm currently using canActivate with route Guard from angular to block users to access /my/specific_url_route. Indeed, I want to block some users (not listed in a list on my database) from…
0
votes
1 answer

Lock/deny url from users (angular guard)

I would like to block url access from unauthorized users. I'm currently using canActivate with route Guard from angular for blocking no Admin user to access /admin route (that's works OK). But now, I have an other use case that is a bit complex: I…
0
votes
0 answers

Property 'canActivate' in type 'AuthorizationGuard' is not assignable to the same property in base type 'CanActivate'

I upgraded my Angular application to Angular 14 and when I tried to run "ng build," I came across this error: "Property 'canActivate' in type 'AuthorizationGuard' is not assignable to the same property in base type 'CanActivate'." This is the…
0
votes
1 answer

How to stop my angular service guards from forcing my application to route to previous page without user input (clicking)

l'm working on a angular application and l have two service which are after login service and before login service. when l use these two guards my application routes itself after every 10 minutes e.g. let's say l navigate from home page to account…
0
votes
0 answers

Infinite loop in Angular's canActivate route guard

In a very very worst case, If you see that the API which is used to fetch the permitted features for an authenticated user, responds with empty feature list or simply the call fails, means an authenticated user has no permitted feature for the…
0
votes
0 answers

I need my Angular app to wait for the server to send the authentication cookie before canActivate() is called on the auth guard

I have an angular app, and authentication works, but when you open a new tab, the auth guard doesn't see the auth cookie(because the cookie hasn't arrived yet) and so the guard doesn't let you into the website. So I'm just trying to make multiple…
fewaf
  • 145
  • 13
0
votes
1 answer

Using NGRX in Router Guard

Need some help with complicated Initialization using NGRX I'm using a CanActivate guard for one of my routes to ensure my NGRX store is initialized with the necessary data for my component. I'm following the example in this post…
millerbill3
  • 199
  • 2
  • 16
0
votes
2 answers

alternative way for canActivate in angular

In my angular 12 project, I have applied canActivate on routes but due to which routes are not working on browser page reload. In canActivate , i am checking data is present or not in localStorage for currentUser. but when I reload page I didn't get…
ganesh
  • 416
  • 1
  • 11
  • 32
0
votes
1 answer

How to use same route guard for different routes that differ in authorization logic

For my Angular 6 project, I have one canactivate AuthGuard to load ComponentA. I want to know can I use the same AuthGuard for component B where it's the authorization logic is exactly opposite to component A? Let's say the logic to authorize…
LearnToCode
  • 169
  • 1
  • 5
  • 19
0
votes
1 answer

Angular How to implement CanActivate guard with HTTP Get call

For my Angular 6 project, we want to use CanActivate guard to check authorization. To implement this, I need to call getSummary() http get call from app.service and perform some logic from its response to provide authorization. The Logic goes as…
LearnToCode
  • 169
  • 1
  • 5
  • 19
0
votes
2 answers

Angular canActivate httpClient infinite loop

I have code like this: auth.guard.ts canActivate(): void { const token = localStorage.getItem('token'); const refreshToken = localStorage.getItem('refreshToken'); if (!token || !refreshToken) { this.router.navigate('/login'); …
ame
  • 773
  • 9
  • 21