Questions tagged [angular-router-guards]

To find more information :

289 questions
0
votes
0 answers

Initializing Angular2 app with client id using routing

I'm trying to kickstart my app by providing it a client id by using routes: www.mysite.com/11298/[any page] 11298 would be the client id and user can navigate to any page under that route. So basically the clientId will always be in the address,…
0
votes
1 answer

Are there options / variables for canActivate in Angular 4

I'd like to decline access to routes based on the rights the user has. So i have a table inside my mongoDb with the userRights and two simple guards actually. One for logged in Users and one for Administrators. So now i would like to give the user…
Sithys
  • 3,655
  • 8
  • 32
  • 67
0
votes
1 answer

Angular - Provide guards across different modules

Basically I have the following Angular modules at the moment: landing admin core shared What I would like is to register a new guard called AuthenticationGuard within the shared module and provide it accross the different modules. At the moment it…
0
votes
1 answer

Angular 2+ Routing -- Routing based on user input

Currently in our project, we are using Angular's Router to define our routes. We have a wizard-esque single page app that has next and previous buttons on each page that define which route to go to next and previous respectively. These next and…
0
votes
2 answers

How to protect route in angular4

I have Login/Create Account in My application. I want the user will not be able to see login/create account if user is already logged in. I am using an Authguard to protect the route: @Injectable() export class AuthGuard implements CanActivate { …
0
votes
1 answer

How to navigate to external URL without Angular prepending "localhost:xxxx"?

I'm trying to write a guard that, if the user is not logged in, redirects to an external service (say, Instagram), if (!loggedIn) { this.location.go(this.instagramLoginUri); } where location is an instance of Angular's Location and the URI is…
Thorsten Westheider
  • 10,572
  • 14
  • 55
  • 97
0
votes
0 answers

Angular - I'm having trouble getting canDeactivate working with my modal for a route

Scenario: Tech: Angular version 5 app using typescript and webpack. I Have made a canDeactivate guard to see if a users wants to leave the current route. When the user tries to navigate to another route a custom modal needs to appear that I've…
0
votes
1 answer

Angular 4 child route to always include param from parent

I have an Angular 4 webapp, that currently hosts a multi tenant site. An example url would be something like www.example.com/tenant/ I have setup my routes as follows, to allow myself a 'tenant guard' ensuring I always have this property before…
0
votes
1 answer

Why does refreshing on guarded page redirect me to root, and not my specified redirection?

I am using Angular 2 framework. I have set up my app-routing module so that I am directed to a sign on page immediately (using pathmatch 'full' and redirectTo:'signOn'. All other routes in my app-routing module have canActivate:…
0
votes
0 answers

Angular Routing issue when navigating programatically, Old component stays in DOM and not destroy

Duplicate Question: Yes. Here it is. As above question is already asked before but not found any useful answers due to question not properly demonstrates the problem. Scenario / Problem: I'm using Angular4 and my project is based on Lazy Loading.…
0
votes
2 answers

Handling Guards with redirections, callbacks and unknown paths

For a project, I have a Router with those available paths : const appRoutes: Routes = [ {path: '', component: AppComponent}, {path: 'dashboard', component: DashboardComponent}, {path: 'leaderboard', component: LeaderboardComponent}, {path:…
Quentin Laillé
  • 125
  • 1
  • 12
0
votes
0 answers

Angular 2 Guards: canLoad() Is Firing Twice any Reason?

canLoad Is Firing Twice On Rejection or Even In Acceptance export const ROUTES: Routes = [ { path: 'Inbox', canLoad: [CanActivateViaAuthGuardService], loadChildren: 'LazyLoaded module', } ] canLoad…
0
votes
1 answer

Auth Guard is applied on Lazy Loaded Modules in angular2 but still it is Redirecting Despite of Rejection canLoad Is Not Working

Assuming Return false will be returned on authentication either on http call but for now i am returning false from CanLoadChildren() Method Inorder to test canLoad But despite of calling canLoad and returning false canLoad still loads Module and…
0
votes
1 answer

Trigger guard to re-render component when change url manually via browser

I setup routing like this { path: ':parent', component: ParentComponent, resolve: { data: ParentResolve }, children: [ { path: ':child', component: ChildComponent, resolve: { …
Thien Hoang
  • 625
  • 3
  • 12
0
votes
1 answer

Angular route guards - issue with call signatures

I'm trying to build a route guard class to only allow admin users to visit a specific page. Here is my admin.guard.ts import { Injectable } from '@angular/core'; import { CanActivate, Router } from '@angular/router'; import { UserService } from…
Dave
  • 3
  • 2