152
questions
1
vote
1
answer
33
views
Angular 18: How to redirect on result of resolve
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 ...
2
votes
2
answers
54
views
How to prefix automatically language in path of route with Angular 14
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 ...
0
votes
0
answers
50
views
Calling canActivate function of all providers implementing CanActivate in Angular
I created a .NET DLL I want to use together with an Angular UI implementation.
The DLL offers some basic operations such as job monitoring. I also implemented some basic authentication that provides ...
1
vote
1
answer
145
views
How to implement state managed by auth reducer in angular auth guard using new CanActivateFn instead of deprecated CanActivate?
// auth.guard.ts
export class AuthGuard implements CanActivate {
constructor(private store: Store<fromAuth.AuthState>, private router: Router) {}
canActivate(): Observable<boolean> {
...
0
votes
1
answer
97
views
Upgrade from Angular 7 to 14 - routing problem -redirectTo and canActivate cannot be used together
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 ...
1
vote
3
answers
124
views
Error using HttpClient in canActivate class | [ERROR] NullInjectorError: No provider for _HttpClient
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 :
...
2
votes
1
answer
838
views
Service Injection in CanActivateFn - Angular 16.2
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 '@...
0
votes
0
answers
315
views
How do I use a CanActivateFn to hide a link?
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 '@...
0
votes
1
answer
77
views
Authorization Issue with Angular Auth Guard canActivate method
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 ...
3
votes
1
answer
2k
views
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 ...
0
votes
2
answers
986
views
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 ...
0
votes
1
answer
1k
views
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 ...
1
vote
1
answer
60
views
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 ...
1
vote
0
answers
261
views
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 ...
1
vote
1
answer
1k
views
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 ...