Questions tagged [angular-route-guards]
89 questions
0
votes
1 answer
canActivate and NGXS selector
I have NGXS selector in SomeService
@Select(state => state.sample)
public sample$: Observable;
I am using it inside an Angular RouteGuard like this
getSample(): boolean {
this.someService.sample$.subscribe({
next: (sample: Sample)…

Murali
- 49
- 9
0
votes
1 answer
Angular- Route Guard always redirects to home page before navigation
I am trying to implement a route guard on my website. It checks for the token and then returns true or false. It is supposed to redirect if it returns false. However, when it is supposed to navigate it firstly goes to "/" route before going to the…
user12706327
0
votes
1 answer
Errors while implementing Angular 8 Route (Auth) Guards
So I was trying to implement Route Guards for my webapp but came into a lot of errors. What did I do wrong?
My webapp consists of multiple routes, one of which is dashboard, which needs to be protected by a login component. That's exactly what I…

Munchkin
- 857
- 5
- 24
- 51
0
votes
2 answers
Waiting for a value to return in Angular route guards
I'm using Ionic with Angular.
Inside one of my route guards, i need to see if a firestore document is created or not and the return a boolean value for it and this takes some time to get the response from the server however the route guard does not…

Shakar Bakr
- 57
- 1
- 10
0
votes
1 answer
canActivate routeguard with nested observables using switchmap operator works only from browser
I am using firebase with authentication and firestore. Authenticated users are stored in database upon signup with extra roles field where some user have 'admin' role. I want to protect the admin route and i use the canActivate route guard. In the…

Nándor Szűcs
- 151
- 1
- 9
0
votes
2 answers
How to use Required and Query parameters together - Query parameters are null
So I am trying to navigate to a timesheet route.
The route takes a name for an employee as a router parameter, and a start and end date as query parameters.
this.router.navigate(['/timesheet', this.name], { queryParams: { start_date: startString,…

Tom O'Brien
- 1,741
- 9
- 45
- 73
0
votes
2 answers
angular authguard redirecting to /
i've changed my authguard to fetch the user object if it is empty. i'm just storing the token in the storage. i see the console.log "role and user ok" and the correct url /member but it redirects me always to / and not to /member in my case.
…

markus
- 475
- 10
- 27
0
votes
2 answers
How to use CanActive/ CanDeactive route guard to restrict user to navigate back to open unauthorized pages, after user is logged in Angular 6
I have two open routes (eg: /home, /details). After user is logged in, I want to restrict the user to go to these pages, till he logout, by direct change in URL, or hitting back button.
I have used AuthGuard, for restricting users to go to protected…

alyson_216
- 136
- 14
0
votes
1 answer
Angular / Firestore - Route guard for login screen - Is it possible to check the user that's trying to access the route?
I have an angular application and a route guard.
If the user ends up on domain.com/login whilst they are logged in, I would like to forward them to another route.
However, one user account has an attribute of 'admin' in firestore (admin: true).…

Que
- 957
- 2
- 14
- 35
0
votes
1 answer
Angular 6 - Route Guard based on firestore node values
I'm currently building an Angular project with Firestore. I have a users collection which contains a users uid plus their name, email and company name. Upon logging in, I can successfully take the users uid, look up the document in firestore and…

Que
- 957
- 2
- 14
- 35
0
votes
1 answer
In Angular, is it possible to load different modules depending upon whether the user is authenticated or not?
For example, the URL: www.example.com should load one module if the user is authenticated, else it should load a different module.
I have tried using guards, but it didn't work as I expect it to.
I am pretty new to Angular. It would be much…
user7366809
0
votes
1 answer
Can I read route parameter's value from the `canActivate: AuthGuard`?
{
path: ':l/bla/bla/bla', component: ..., canActivate: [AuthGuard]
}
Then AuthGuard's constructor:
constructor(
private readonly router: Router,
private readonly activedRoute: ActivatedRoute) { }
... however both .params and…

Zazaeil
- 3,900
- 2
- 14
- 31
0
votes
0 answers
Restrict refreshing the page |Browser Restriction | angular 6 |
I am using angular 6 for my project, I need to restrict the user from refreshing the page.
when the user tries to click on the refresh button of the browser or press ctrl+f5 etc, I would like to restrict the user and show the page for it.
show…

Hitesh
- 4,098
- 11
- 44
- 82
0
votes
1 answer
In Angular, if Login is done, the user should'nt be allowed to go Login page again until he logs out. How to implement it in Angular
After login, until the user logs out , the login page route should not be accessed. how to implement it in Angular. Please give a detailed explanation with necessary code.
import { Injectable } from '@angular/core';
import { Router, CanActivate,…

Immanuel John
- 271
- 2
- 9
0
votes
1 answer
Route Guard: How can I set true or false based on params set from HttpPost?
My code:
@Injectable()
export class UserRouteAccessService implements CanActivate {
authorized = [
'AGREEMENTS_VIEW',
'PROSPECTS_VIEW',
'AGREEMENTS_INSERT_UPDATE',
'PRODUCTS_INSERT_UPDATE',
…

Francesco Giberti
- 95
- 17