To find more information :
Questions tagged [angular-router-guards]
289 questions
0
votes
1 answer
Angular routing with Msal Azure AD integration
I am on Angular 13, integrated with Azure AD using MSAL. My issue is as soon as the user successfully logs in , the logincomponent is not displayed. But when I do a page refresh then the login component displays. How do I get login component to…

user1005310
- 737
- 2
- 12
- 40
0
votes
1 answer
Angular/rxjs: check Auth Data in Guard after page reload/refresh
Have an auth service which fetches data immediately after auth:
export class AuthService {
profile: BehaviorSubject = new BehaviorSubject(undefined);
constructor(private auth: Auth, private http:…
user16831793
0
votes
0 answers
trigger canActivate every 10 minutes
I am currently using a canActivate-service for my angular parent route and therefore for all the childroutes. looks like that for example
const routes: Routes = [
{
path: '',
canActivate: [ServiceWhichShouldRunEvery10Minutes],
runGuardsAndResolvers:…

s.stkvc
- 127
- 1
- 2
- 12
0
votes
0 answers
Route Guard Angular - How to reconize a reload page instead of a load page via URL (manually change). How can I differenciate the two cases?
export class RouteNavigateService implements CanActive {
private loggedIn: boolean = false;
private navigateTo: boolean = false;
constructor(private router: Router){ }
canActivate(route: ActivatedRouteSnapshot, state:…

Fabio C.
- 1
- 1
0
votes
1 answer
Angular Guards: Prevent to manually access an URL but authorize refresh
I've created a Guard that prevent a user to manually access an URL and it's working fine.
The problem is that when I refresh the page, the Guard redirects me.
Here's the code:
export class NavigationGuard implements CanActivate {
…

PepeW
- 477
- 1
- 8
- 24
0
votes
1 answer
Angular Dynamic URL in lazy loaded module
I have page which renders content based on the params in the url, current route samples are given as follows,
domain.com/page/:pageId (domain.com/page/123456) renders Home Page
domain.com/page/:pageId (domain.com/page/567890) renders Offers…

Tom
- 183
- 1
- 1
- 9
0
votes
1 answer
How to parse data from component into Guard in Angular
I want to show a prompt on screen to the user if they are trying to navigate away from a page in which they have made changes to a form. I have created a Guard so far, and successfully got it to log something in the console when the user navigates…

TreyBCollier
- 213
- 3
- 8
0
votes
3 answers
'Not all code paths return a value ' Angular
I am building a small project and I am basically dealing with Adding an Angular route guard. I ran into the error 'Not all code paths return a value.' What could be wrong? I am new to development.
auth.guard.ts
import { map } from…

BRYAN MAKINI
- 11
- 1
- 3
0
votes
2 answers
Angular how to disable authGuard on particular child page
can anyone suggest best way to disable authguard (applied on parent level) on a single child page.
ROUTES:Routes = [
{
path: '',
component: AdminComponent,
children: [
{
path: '',
…

Bhavesh
- 819
- 1
- 17
- 31
0
votes
1 answer
Http call inside Angular Guard to verify JWT
Is it a good idea to call a server in the guard in order to verify if jwt is valid?
I'm storing jwt on the frontend, but I don't know if that token is expired or blacklisted unless I contact the backend. Also, I don't know the user's role, which is…

while1618
- 53
- 7
0
votes
1 answer
How to implement Auth Guard : Angular
I have created an auth guard like below based on the auth token from local storage. If the token is not present in local storage, it is working and redirecting the user back to the login page. But if the token is present in storage then I still can…

RAHUL KUNDU
- 745
- 2
- 12
- 33
0
votes
1 answer
canActivate always taking to login form in Angular?
I am new to angular. I am using canActivate guard but when I apply it to the route, it always takes me to the login page despite the guard returning true.
Please help.
guard code:
import { Injectable } from '@angular/core';
import { CanActivate,…

Ahmad
- 89
- 2
- 15
0
votes
1 answer
Angular AuthGuard and login persistence: Router automatically redirects to non-truthy route even if logged in
As the title suggests, I want to protect routes via canLoad. This works to some extent. However, I have two issues with the code.
Here are my code snippets
AppComponent
ngOnInit(): void {
…

Viany Manuel
- 33
- 6
0
votes
0 answers
Angular routing: How to access parent route param in child canLoad
Here's what I have for routes:
{
path: ':class_id',
component: Class_Root_Component,
children: [
{
path: 'members',
canLoad: [ Class_Members_Can_Load ],
loadChildren: () =>…

skwny
- 2,930
- 4
- 25
- 45
0
votes
1 answer
Authentication + Ionic + Firestore + Guard (canActivate) - Access Permission
I am creating an application in Ionic that uses Firebase to authenticate users. As soon as an authentication is performed successfully, save its data in the Firestore. One of the items in the collection on the user's Firestore is the 'activeUser:…

Marcelo Nunes
- 1
- 1