Questions tagged [canactivate]

145 questions
0
votes
1 answer

EmptyError: no elements in sequence when using takeWhile in angular guard

We have a canActivate guard which should return Observable(boolean). The boolean status is obtained form service, where we need to poll 3 times with 1 sec interval until we receive response 'true'. Problem is that whenever takeWhile returns false we…
Borislav Stoilov
  • 3,247
  • 2
  • 21
  • 46
0
votes
0 answers

Uncaught (in promise): TypeError: guard is not a function - when Class extends Another Class

The same configuration that I have below was working fine just before one day and not working any more on my machine. I checked on other machine and it is still working fine on those machines. Here is what I'm doing. App-Routing: const routes:…
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', …
0
votes
0 answers

Promise from check login method is not returning the promise to canActivate()

I have the following login method: login(username, password) { let headerOptions = new HttpHeaders(); // headerOptions.append('Access-Control-Allow-Origin', '*'); // headerOptions.append('Access-Control-Request-Headers', '*'); //…
alim1990
  • 4,656
  • 12
  • 67
  • 130
0
votes
1 answer

CanActivate don't display the desired component when the returned result is true

I have the following API function: checkLoggedInAdmin():boolean { //Get the JWT token from local storage let jwt = localStorage.getItem('jwt'); let httpParams = new HttpParams().set('jwt', jwt); let headerOptions = new…
alim1990
  • 4,656
  • 12
  • 67
  • 130
0
votes
2 answers

CanActivate and canLoad not working after Module loads

I have an applications that lazy load module. once a module is loaded, all components loads as well and so i am unable to use can activate to guard individual component of the lazy loaded module. Is there a way I can lazy load a module and then…
valentine
  • 457
  • 8
  • 17
0
votes
1 answer

implementing canActivate auth guard in angular

I have a service with this function that returns true or false on rather or not a token is valid loggedIn() { return this.http.get('http://localhost:3000/users/validateToken') .map(res => res.json()).map(data => data.success); } I have a auth…
Anders Pedersen
  • 2,255
  • 4
  • 25
  • 49
0
votes
1 answer

can activate route guard angular cannot satisfy interface while executing logic

I have the following can activate route guard class import {OnDestroy } from '@angular/core'; import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router'; import {Injectable} from…
user9487981
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

Return A boolean Promise from a function, to be used in the CanActivate function [Angular Guard]

I want to return a boolean promise from this function, any help please? getSectionsList() { let sections: string[] = []; var ref = this.db.database.ref(`instructors/jDlPCWMMJ8YmD9tMO3shTshM5sx1/sections`); return ref.once('value').then(function…
0
votes
0 answers

add a button(which is used to activate another app) on win 10 toast

I'm looking for methods to add a button on win 10 toast. I've already made a exe file which is able to call the toast every time I launch it. But I have no idea how to add a button on my toast(any API in MSDN(C++)?) and the button is able to…
Kevin Chiu
  • 53
  • 1
  • 6
0
votes
1 answer

Understanding canactivate and routes in angular 2

I am trying to check if a user is authorized and if not direct him/her to login page. I actually managed to do that but i am having an hard time how the mechanism works. please see below code. canActivate(route: ActivatedRouteSnapshot, state:…
rematnarab
  • 1,277
  • 4
  • 22
  • 42
0
votes
1 answer

Using angular 2 guard. How to Keep user logged in when refreshing the page?

Here is my angular code for routing in app.module.ts file. const appRoutes: Routes = [ {path: '', component: LoginformComponent}, {path: 'dashboard', component: DashboardComponent, canActivate: [AuthenticationGuard]}, {path: 'user', children: [ …
LSampath
  • 138
  • 1
  • 3
  • 11
0
votes
3 answers

Guard always redirects to the default route

I have a guard that checks a user's session. I am creating an observable from a promise and returning that observable. Unfortunately the router always redirects me to homepage on refresh. I guess it has to do with the observable as when I simply…
Bogdan
  • 77
  • 1
  • 9
0
votes
1 answer

Unable to use canDeActivate or canActivate in Angular

I am trying to use the canDeActivate and canActivate and I am using it as below with Angular 4. I am getting a no provider error for the same. What is wrong with the implementation or what is the right way to implement this cleanly and…
Gary
  • 2,293
  • 2
  • 25
  • 47
1 2 3
9
10