Questions tagged [auth-guard]

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

164 questions
1
vote
1 answer

NestJS AuthGuard that handles both GraphQL and REST

According to the docs, in order to use AuthGuard for the auth of GraphQL resolvers, we have to override getRequest method like this: getRequest(context: ExecutionContext) { const ctx = GqlExecutionContext.create(context); return…
Ryan Ro
  • 304
  • 2
  • 11
1
vote
2 answers

AngularFireAuthGuard redirectUrl after login

I use firebase and AngularFireAuthGuard to protect specific routes, so that only authenticated users are allowed to access them. In particular, my MainComponent and MgmtComponent should only be accessible to AUTHENTICATED users. const…
Herbi
  • 103
  • 8
1
vote
2 answers

Angular - Response is not assignable to type 'request?: HttpRequest

I try to write an AuthGuard in Angular but i get the following Error: Type 'typeof AuthServiceService' is not assignable to type '(request?: HttpRequest) => string | Promise'. Type 'typeof AuthServiceService' provides no match for the signature…
Léon Zimmermann
  • 123
  • 1
  • 14
1
vote
1 answer

Angular, User authenticates on Login but does not route to dashboard. Removing AuthGuard works

I am new to angular and spend around 2 to 3 hours online trying to navigate from login to dashboard if user authenticates. I am able to route to dashboard if I don't user canActivate: [AuthGuard]. However as soon as I add canActivate: [AuthGuard] I…
1
vote
1 answer

Question on Angular guard with Observable

hope I can get some clarification here and learn things as I go. So I've got an AuthService which checks localStorage for a key and the values in it. This is an observable and .next the value back. In the Guard, I'm referencing this and it works out…
newbie
  • 21
  • 1
  • 3
1
vote
2 answers

Grabbing the OAuth Token From URL After Redirect URI Callback Using Angular

I redirect my Angular application to the Spotify Login (https://accounts.spotify.com/authorize) Once they login they are redirected back to http://localhost:4200/callback. This URL has a token attached to it. But it immediately redirects to (I want…
larson-adam
  • 57
  • 3
  • 8
1
vote
1 answer

How to create an async auth-guard for one of ionic's lazy loaded tabs

I have a simple Ionic 4/5 tabbed application (I started from their tab starter). I would like to make one of the tabs guarded by authentication. Here's what I want to achieve: have one of the tabs reserved for logged in users, profile management,…
Attila Kling
  • 1,717
  • 4
  • 18
  • 32
1
vote
1 answer

No auth value after successful login using admin guard

Can someone help me understand what I am doing wrong? Here is my config/auth.php file 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'admin' => [ 'driver' => 'session', …
Siddhanta das
  • 29
  • 1
  • 6
1
vote
1 answer

Verify token with API in Angular8 canActivate method of AuthGuard

I want to do some validation on each refresh request for some routes. So I'm using Angular AuthGuard. The problem is in canActivate method I want to perform validation with online API. API is /token/verify which simply gets token variable (jwt) and…
1
vote
1 answer

Redirect after AuthGuard callback in Angular

I have two routes that require Angular canActivate: [AuthGuard] const routes: Routes = [ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', component: HomeComponent }, { path: 'projects', children: [ { path:…
Mercurial
  • 3,615
  • 5
  • 27
  • 52
1
vote
2 answers

Angular how can I retrieve from authguard?

I have an Angular-springboot program with jwt authentication, I would like to know how I can once logged in on angular, recover the data of who logged in, for example the username. I looked at some guides on authguard and httpinterceptors but I am a…
1
vote
1 answer

Angular 8 .next doesn't seem to work as expected

I am trying to create a service that authenticates a user and stores the token in the localStorage. I want other services (specifically the auth guard) to be able to access the current user, so I have set up the constructor of the authentication…
r3plica
  • 13,017
  • 23
  • 128
  • 290
1
vote
1 answer

Second Login after first logout does not work

I've have written an API which returns a token and an userid if the login credentials are correct. Those do I save into the local storage, like this: If the Users Token isn't valid anymore I clear the local storage: localStorage.clear(); The Login…
Xaviius
  • 25
  • 6
1
vote
1 answer

Angular 6 - NavigationCancel - reason: "guard of the route returned false" - before guard even finished

I've got routes with lazy loading and onLoad Guard. Within the guard I grap the navigation menu from backend (you only see naviagtion points which you are authenticated for) and compare the route with the route-list from backend. The problem: when…
Jana
  • 266
  • 3
  • 5
  • 18
1
vote
1 answer

Component is loading before canActivate returns the result in angular 4 when integrated with keycloak

I have integrated keycloak with application, I have written AuthGuard to protect specific routes.canActivate works fine but the component for the route also loading and another API calls also getting triggered in background. How to load component…
Anusha M
  • 19
  • 4