Questions tagged auth-guard

Explore the latest questions and answers asked by our top developers.

Looking for the right way to add AngularFireAuthGuardModule to angular 13

First of all I use: @angular/cdk 13.2.0-next.0 @angular/cli 13.0.4 @angular/fire 7.2.0 and "firebase": "^9.3.0" I don’t know how add the AngularFireAuthGuard to the app. At this point my pp.module.ts is like this: … import { AngularFireAuthGuardModule } from ‘@angular/fire/compat/auth-guard’; @NgModule({ declarations: [ … ], imports: [ … ServiceWorkerModule.register(‘ngsw-worker.js’, { enabled: environment.production, registrationStrategy: ‘registerWhenStable:30000’ }), provideFirebaseApp(() […]

By Max Hesari
Categorized as angular, angularfire, auth-guard, firebase Tagged , , ,

Angular MSal conditionally disable route guard based on environment variable

I have a routing module set up as shown below where I use MsalGuard to require authentication before accessing child routes. This works, however, when I’m testing locally I would like to have the MsalGuard be disabled based on an environment variable. How can I accomplish this? I have tried using canDeactivate on my route […]

By mo maat
Categorized as angular, auth-guard, msal Tagged , ,

If I refresh the page when I’m logged in, the Guard redirects me to the login page

If I refresh the page when I’m logged in, the Guard redirects me to the login page. Is there a way for redirecting to the login page only if the user truly log out? I am using frontend as angular (version: 12.2.13)and backend as firebase. Source: Angular Material Quesions

Angular Universal – Home page contnet load first for auth gaurded page on refresh

I have added angular universal in my angular project. This project consist of normal web pages and admin dashboard. All the normal web pages and admin pages works fine. The only problem is with admin pages is while refresh. The dashboard on refresh it first shows home page content and after few second it redirect […]

Angular Router endless loop with canActivate / redirectTo

I’m having trouble getting a redirect in my routing module working, and adding an AuthGuard in CanActivate complicates it even further. Here is a simplified router: const routes: Routes = [ { path: ‘login’, component: LoginComponent, }, { path: ‘home’, component: HomeComponent, }, { path: ‘secret’, component: SecretComponent, canActivate: [ AuthGuard ] }, { path: […]

By Luke Pe a
Categorized as angular, auth-guard, router Tagged , ,

Generalize jwt expiracy in Angular

I’m using Node/Express, Angular and jwt in order to build a web application. I’ve been looking for a way to check whether the jwtoken has expired in Angular and I’ve come across this solution: import {JwtHelperService} from ‘@auth0/angular-jwt’; . . constructor(private jwtHelper: JwtHelperService) { } ngOnInit() { if (this.jwtHelper.isTokenExpired(token)) { // token expired } else […]

By F lix
Categorized as angular, auth-guard, authorization, jwt, token Tagged , , , ,

The auth guard is not working in angular 12

I’m using visual studio code for my latest project.In my project i want to implement the auth guard for route security I’ve just added the auth.guard.ts file but its not working.I posted my code below 1.auth.guard.ts auth guard code app.routing app.module Source: Angular Questions

Check multiple condition before login in Using auth guard

I am trying to check multiple condition to let user login. I was able implement authguard when user is logged In successfully. Not only user need validate but also need to meet the criteria to login. Here is How I have implemented auth guard to check if user is Sign In or not. export class […]

How can i use canActivate() to block access to certain routes?

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 can simply access to that profile while i am not supposed to . Source: […]

By BHIRI Yosri
Categorized as angular, auth-guard, canactivate, routes Tagged , , ,

CanActivate on pagination in Angular

I have server side pagination on a list screen in angular. When I click on the link to visit the screen, sometimes the pagination number doesn’t appear and I have to double click the link to get the number. I have used CanActivate guard on the screens so that the screen gets displayed only when […]

By Ahmad
Categorized as angular, auth-guard, canactivate Tagged , ,
1 5

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us