Questions tagged [auth-guard]

Refers to Angular's AuthenticationGuard class, a route protection mechanism most commonly implementing `canActivate`.

164 questions
39
votes
5 answers

Angular's "CanActivate" interface is deprecated. How to replace it?

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 that both CanActivate and CanActivateChild are…
kellermat
  • 2,859
  • 2
  • 4
  • 21
12
votes
3 answers

Can't resolve all parameters for AuthGuard: In my AuthGuard service

I have a code for AuthGuard.service.ts as follows. import { Injectable } from '@angular/core'; import { ActivatedRoute, CanActivate } from '@angular/router'; import { userLoginService } from './userLoginService'; export class AuthGuard implements…
roopteja
  • 721
  • 2
  • 16
  • 36
7
votes
6 answers

Angular AuthGuard is not working

I am using angular CanActivate Authguard interface to protect my component. @Injectable() export class AuthGuard implements CanActivate{ constructor(private router: Router, private authService: AuthenticationService) {} canActivate(route:…
user3692033
  • 585
  • 3
  • 8
  • 21
6
votes
2 answers

In Angular -> how to check if the user has permission using role-based access with the role save in the data base

I'm trying to make a role-based access for my app in angular, and I need some help because I'm newbie in angular ... First this is what I have in the route where I establish which roles can access it... from app-routing.module.ts { path:…
5
votes
1 answer

NestJs showing 401 after following doc exactly

I am begginer at Nestjs. I trying to get access-token from login route. I followed the exact steps shown in NestJs Authentication docs. But I getting 401 unauthorized every time. I am frustrated at this point. If someone could help me to get the…
5
votes
0 answers

app component loads even before angular guard checks for data from API

i have an angular app whose app.component.html looks as below:
and 'app-nav-bar' is a component which gets loaded on launch of this angular app, whose…
Lisa
  • 655
  • 3
  • 10
  • 34
5
votes
5 answers

check if a route exist in angular 2

I want to check if a route exists in an angular project. For example user types http://localhost:4200/#/timestamp in the url bar and timestamp does not exist in the project, how will you be able to check without redirecting?
user8653311
4
votes
3 answers

Angular Auth Guard with a Promise and if statement

I want to use a guard to decide whether or not a user can navigate to the login pag, but I know my logic is faulty because of a Promise. See my code below. canActivate(): boolean | Observable | Promise { if…
4
votes
2 answers

Angular Universal - Auth Guard pending problem

I'm using popup login with Angular Material, when I added Angular Universal the auth guard is the problem. If some route is protected by auth guard the page just start pending and never finishes. Behavior without Angular Universal is when page is…
Todor Pavlovic
  • 160
  • 1
  • 11
4
votes
1 answer

Angular MsalGuard for Authentication and written own Guard for Authorize, Need to wait for authentication first

I have an application where there are two guards (MsalGuard - for Authentication, AuthGuard - written own code to authorize whether the user is having access to that particular page). Using the lazyloading while loading the modules. Please find the…
4
votes
1 answer

Hide the navbar in angular 8 (auth-guard routes are not recorded in routes.event)

All, Before implementing the auth guard, I was able to hide my Navbar from login and registration screen. By reading the route events in component.ts and hiding the nav-bar by ngIf. After I implemented the auth guard the route made by auth guard to…
4
votes
1 answer

Angular 7 navigate is changing URL accordingly BUT doesn't load the component

after trying every other solution, i am still stuck with my problem which is : trying to navigate to other component, URL changed but i stay on the same page, destination component is not load. Explanation: When the user arrive on App, based on…
Djulian
  • 135
  • 1
  • 8
4
votes
1 answer

How to get a service response before loading a component Angular 4?

I have a service that makes request to an api and according to its response I should decide that a component must be loaded or not. but because of a time spent to receive the response, component loads regardless of response status, and after some…
Hamid Hosseini
  • 217
  • 4
  • 8
3
votes
1 answer

Angular Route Guard - Not redirecting to login page correctly

I'm using a can activate guard and a Node server with JWT's. Routing during normal operation works well. However, when a token has expired and the page still exists in the browser, I'm able to click around in the angular app, though no API data…
3
votes
2 answers

Email Verification in laravel 5.7 for admin guard

I want to implement must verify in admin routes, i have admin guard and all routes related to admin, how can i achieve this functionality for admin guard in Laravel 5.7
1
2 3
10 11