Questions tagged auth-guard

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

Angular Auth Guard is not navigating to new Route

My Auth Guard is working as intended in regards to attempting to search a URL without logging in. However, when signing in, the navigation in the URL does not change and the user is not routed to the correct page. It is*, however, running the correct sign in method to reroute to the intended page, […]

By ACDev
Published
Categorized as angular, auth-guard Tagged ,

Read only permissions in Angular by route

Currently i have the type of permission on a service and i want to set read-only by path. Is there any way to do it? Something like the auth guard. Thx Source: Angular Questions

By David Rod
Published
Categorized as angular, auth-guard, permissions Tagged , ,

Read/Write only permissions in Angular by route

Currently i have the type of permission on a service and i want to set read-only by path. Is there any way to do it? Something like the auth guard. Thx Source: Angular Questions

By David Rod
Published
Categorized as angular, auth-guard, permissions Tagged , ,

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<boolean> | Promise<boolean> { if (!this.localStorage.getObject(‘isInitialized’)) { this.router.navigate([‘/locaties’]); return true; } return false; } I know what I’m […]

AuthGuard security not working as expected

In Angular I have implemented JWT authentication. While trying to implement AuthGuard security for role based authentication , it is not working Here is my code.. Auth.guard.ts import { Injectable } from ‘@angular/core’; import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from ‘@angular/router’; import { BehaviorSubject } from ‘rxjs’; import { User } from ‘../data/schema/user’; import […]

routing redirects always to homepage component after refreshing, how do i stop this happening?

im building an angular app with very basic authguard authorization. in app i also have 2 components that render depending on the user if its logged or not. problem is, always that i refresh page on some component, routing doesnt stay on that component but redirects to homepage. Ive like to stop this to happen. […]

angular mutiple observable guard dont run with ordering

hi i have two guard in my routing. my first guard is like below code canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { const token = localStorage.getItem(‘token’); if (token) { if (this.authStore.getUserValue()) { this.user = this.authStore.getUserValue(); return true; } else { return new Promise((resolve, reject) => […]

By arman
Published
Categorized as angular, auth-guard, observable, routes Tagged , , ,

Angular + oauth2 problem, auth guard always call initLoginFlow while the API is still fetching

I have an app that using angular-oauth2-oidc package to call the oauth server, after getting the access_token, I will use this token to call Java backend to get user profile back. Now I am facing the problem that is the app won’t wait the java http request complete, and always redirect me to the oauth […]

By rascee
Published
Categorized as angular, auth-guard, oauth-2.0, observable, rxjs Tagged , , , ,

Subscription getting too late in the execution angular

I’m new to angular and my subscription getting late in execution. I can’t use Async Pipes as I’m using custom libraries in my project. here is the subscription function. loadOrganizations() { console.log("loading organizattions"); this.getOrganizations().subscribe( (results) => { const organizationList = []; if (results.organizations) { results.organizations.forEach((element) => { this.appendOrganization(element, organizationList); this.loadChildrenOrganization(element.children, organizationList); }); } this.organizations$.next(organizationList); this.organizations$.complete(); […]

how to subscribe to a observable in our .ts file from authguard.ts

I have implemented an authguard service in which consist of following void service method. loadOrganizations() { console.log("loading organizattions") this.getOrganizations().subscribe( (results) => { const organizationList = []; if (results.organizations) { results.organizations.forEach((element) => { this.appendOrganization(element, organizationList); this.loadChildrenOrganization(element.children, organizationList); }); } this.organizations$.next(organizationList); this.organizations$.complete(); }, (error) => { this.organizations$.next([]); this.organizations$.complete(); } ); } my auth guard service as follows. […]

1 2 3 4

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
faq