Skip to main content
Filter by
Sorted by
Tagged with
3 votes
0 answers
33 views

I have two modules in my Angular application, and I am using lazy loading to prevent a module from being loaded until the user navigates to it. Additionally, I am using canActivate in my route guards ...
Haris Khan's user avatar
1 vote
1 answer
228 views

In the following canActivate function, I need to get the number of Items in a cart. I inject the CartService for this purpose but am getting an error that inject() must be called from an injection ...
koque's user avatar
  • 2,306
1 vote
1 answer
169 views

I have the following code in my old version of Angular import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/...
vinudev's user avatar
  • 87
1 vote
1 answer
913 views

In Angular 18, I am trying to resolve a value before navigation, but redirect to another page based on that value. Please don't link to a page titled "Redirecting Guards and Resolvers in Angular ...
user2977624's user avatar
2 votes
2 answers
108 views

I try to add the language of customer directly in the path like /en/dashboard And if a customer go to the web site with an older link, like /home I want to add automatically the default language in ...
R3tep's user avatar
  • 12.9k
1 vote
1 answer
211 views

// auth.guard.ts export class AuthGuard implements CanActivate { constructor(private store: Store<fromAuth.AuthState>, private router: Router) {} canActivate(): Observable<boolean> { ...
nerdWannabe's user avatar
0 votes
1 answer
184 views

I get this error Error: NG04014: redirectTo and canActivate cannot be used together. Redirects happen before activation so canActivate will never be executed. after upgrading angular 7 to 14. Anyone ...
sourabh's user avatar
  • 33
1 vote
3 answers
156 views

I've some troubles when I want to use HttpClient in a CanActivate class. I want to do some POST request in order to find my token in a Django API. Examples are better than words : auth.guard.ts : ...
Alos's user avatar
  • 11
3 votes
1 answer
1k views

I'm trying to use the value I collect from the Authorization Header in an authGuard. The Service that manages the login successfully logs the value I expect. import { HttpClient, HttpResponse } from '@...
Giuseppe Lepore's user avatar
0 votes
0 answers
361 views

I am using CanActivateFn rather than CanActivate to handle my routing authentication. Here is my app-routing.module.ts: import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@...
Jerome's user avatar
  • 914
0 votes
1 answer
102 views

I am using an Angular authentication guard to handle authorization for each route. I need to call two API endpoints to retrieve user information and current user privileges. With my code, it follows ...
heshjse's user avatar
  • 910
4 votes
1 answer
4k views

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 ...
Pamba's user avatar
  • 832
0 votes
2 answers
1k views

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 ...
syahiruddin's user avatar
0 votes
1 answer
2k views

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 ...
HengHeng123's user avatar
1 vote
1 answer
78 views

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 ...
RandomSync's user avatar
1 vote
0 answers
299 views

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 ...
Lucas's user avatar
  • 11
1 vote
1 answer
2k views

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 ...
Dorian's user avatar
  • 37
0 votes
1 answer
440 views

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 ...
Dorian's user avatar
  • 37
2 votes
1 answer
279 views

I have a generic CanActivate guard and want to alter the matrix params of the corresponding path segment (the one being tested). With given route config: { path: 'parent', canActivate: [...
mumenthalers's user avatar
110 votes
5 answers
132k views

My Angular app includes a simple AuthGuard as shown below and there has never been a problem with it. Recently, I upgraded my Angular version from 15.1.4 to 15.2.0 and since then, my IDE indicates ...
kellermat's user avatar
  • 4,851
3 votes
2 answers
7k views

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 ...
achraf bourki's user avatar
0 votes
1 answer
115 views

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. ...
SkullSrusher's user avatar
0 votes
0 answers
180 views

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 ...
Rezaul Karim's user avatar
-1 votes
1 answer
502 views

I am having an angular 11 app. It throws a 500 internal server error on the route when I refresh the page. This started to happen when I remove the "canActivate" from the route. This only ...
Iishfaaq Ismath's user avatar
0 votes
0 answers
263 views

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 ...
fewaf's user avatar
  • 151
1 vote
1 answer
178 views

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 ...
Tabares's user avatar
  • 4,385
0 votes
1 answer
777 views

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 ...
millerbill3's user avatar
1 vote
0 answers
418 views

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 ...
tshishi's user avatar
  • 11
1 vote
2 answers
3k views

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 ...
Bhavesh's user avatar
  • 1,081
0 votes
2 answers
2k views

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 ...
ganesh's user avatar
  • 482
1 vote
1 answer
467 views

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 ...
pupy frias's user avatar
0 votes
1 answer
755 views

Guys i'm trying to make a auth guard to guard routes that someone who isnt authenticated cannot access. In my AuthService i imported Can Activate like this: import { CanActivate, ...
Paula Bremenkamp's user avatar
0 votes
1 answer
1k views

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 ...
CodeLearner's user avatar
0 votes
1 answer
2k views

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 ...
CodeLearner's user avatar
0 votes
2 answers
321 views

I have code like this: auth.guard.ts canActivate(): void { const token = localStorage.getItem('token'); const refreshToken = localStorage.getItem('refreshToken'); if (!token || !...
meteor's user avatar
  • 861
0 votes
1 answer
1k views

i am protecting all my routes with a single Authguard and right now i am using in each route canActivate: [AuthguardService] my application has 30+ routes and so i need to type this 30 times in each ...
GreekSwiss's user avatar
0 votes
1 answer
309 views

My group and I are building a website using angular for the client side. We're trying to use AuthGuard to lockdown the routes but are having trouble not being able to map to the subject. LoginService: ...
Raevn Belden's user avatar
0 votes
1 answer
1k views

I am struggling to figure out what is going on with my canActivate Method. Currently, I am able to log in and see that my user credentials are being saved and used in both localStorage and a console....
M. Bal.'s user avatar
  • 63
3 votes
1 answer
537 views

I am configuring a guard for my angular app and it happens that when I run the application and log in the first time it works fine, but I configure an error interceptor where I have a condition that ...
Deybi Tabora Paz's user avatar
2 votes
1 answer
95 views

in my program I have a func in canActivateChild that need to occur after canActivate finished , but the child component loads befor canActivate of the parent finish,why? my routing-module: const ...
Hinda's user avatar
  • 21
-1 votes
2 answers
2k views

I have a route guard that checks if a user has access to a resource, before proceeding. After the subscription, I check if the user has access, and if not, redirect using parseUrl or return true. @...
Christian Phillips's user avatar
0 votes
1 answer
385 views

When I reload my page, it always goes to blank page instead of the same page. The reason behind this is canActivate method which is cheking for user's permission gets invoked as soon as user refreshes ...
Sandor Szilard's user avatar
2 votes
2 answers
2k views

When I reload my page, it always goes to blank page instead of the same page. The reason behind this is canActivate method which is cheking for user's permission gets invoked as soon as user refreshes ...
Radiant's user avatar
  • 390
1 vote
1 answer
232 views

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 ...
Tommy Gordon's user avatar
1 vote
1 answer
1k views

I am very new to the angular project. After I clone the project and try to up the project with ng serve. So I am getting an error like. ERROR in node_modules/keycloak-angular/lib/core/services/...
Dasun's user avatar
  • 612
2 votes
1 answer
877 views

I've never done this before and couldn't find a good reference online so I'm asking. I'm building angular web app and want to make a role -> permission system. I've made roleGuard with CanActivate, ...
reznov46's user avatar
1 vote
1 answer
2k views

I observed strange behavior with my CanActivate guard (Angular 10.2.5): export class VersionGuardService implements CanActivate { constructor(private router: Router, private http: HttpClient){ } ...
dzk008's user avatar
  • 81
1 vote
1 answer
2k views

I have used CanActivate to protect a page but it always returning false because of that I can not access the protected router. I tried many ways, but was not successful to fix the issue. I am new to ...
sarasm's user avatar
  • 345
0 votes
1 answer
778 views

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 ...
raviguggilam's user avatar
0 votes
1 answer
2k views

In my application when a user try to see the page "home" he is redirected to the login page (if he's not already logged in). If the user is already logged in, or after he logged in, I want ...
Matt's user avatar
  • 375