angular-route-guards

How to make http post call inside route guard in angular7?

﹥>﹥吖頭↗ 提交于 2020-03-06 09:21:08
问题 I have an Angular 7 app in which I have a post call and on the basis of that post call response I want to make guard active/inactive. I have my route guard like this canActivate = (_router: ActivatedRouteSnapshot): boolean => { console.log('in link expiry guard') let userEmail = _router.paramMap.get('email'); let isAllow; console.log('params : ', userEmail) userEmail = this._utilityService.decryptMsgByCryptoJs(userEmail); console.log('user email : ', userEmail) this._dataService.post(this.

Route Guard: How can I set true or false based on params set from HttpPost?

只谈情不闲聊 提交于 2020-01-16 12:02:47
问题 My code: @Injectable() export class UserRouteAccessService implements CanActivate { authorized = [ 'AGREEMENTS_VIEW', 'PROSPECTS_VIEW', 'AGREEMENTS_INSERT_UPDATE', 'PRODUCTS_INSERT_UPDATE', 'PROSPECTS_INSERT_UPDATE', 'DOCUMENTS_VIEW', 'DOCUMENTS_INSERT_UPDATE', ]; constructor(private router: Router, private securityService: CralSecurityService) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { //boolean var this

Route Guard: How can I set true or false based on params set from HttpPost?

纵饮孤独 提交于 2020-01-16 12:02:06
问题 My code: @Injectable() export class UserRouteAccessService implements CanActivate { authorized = [ 'AGREEMENTS_VIEW', 'PROSPECTS_VIEW', 'AGREEMENTS_INSERT_UPDATE', 'PRODUCTS_INSERT_UPDATE', 'PROSPECTS_INSERT_UPDATE', 'DOCUMENTS_VIEW', 'DOCUMENTS_INSERT_UPDATE', ]; constructor(private router: Router, private securityService: CralSecurityService) { } canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { //boolean var this

CanActivate guards on child routes run before parent Resolve finish

放肆的年华 提交于 2020-01-13 09:06:59
问题 I'm trying to resolve data before navigating to children routes as i have to use that data in children guard. The issue is parent resolver, resolves data after the child guard is fired. Resolver takes long time to resolve data // app.module.ts const appRoutes: Routes = [ { path: 'login', component: LoginComponent }, { path: '', component: SiteLayoutComponent, children: [ { path: '', redirectTo: 'warehouse', pathMatch: 'full' }, { path: 'warehouse', loadChildren: './warehouse/warehouse.module

How to pause the route change in navigationStart router event

霸气de小男生 提交于 2019-12-24 10:59:57
问题 In my application I have routes exposed from packages (node modules). So i couldn't use canActivate or canDeactivate for the routes defined inside node modules. So I started subscribing to all route change in my app component and based on condition i am redirecting the user to different routes. Since the condition has API call, the route change is not paused in the navigationStart instead it completes the routing to other page and once API call is successful the redirect happens to the other

Route Guard: How to make route guard true based on list sent by the server?

≯℡__Kan透↙ 提交于 2019-12-13 10:06:03
问题 I was trying to use route guard in my app that should let you go to a component only if the server sends you some parameters. This is the list of the parameters that the server can send me (not all of them are sent each time) AGREEMENTS_VIEW PROSPECTS_VIEW AGREEMENTS_INSERT_UPDATE PRODUCTS_INSERT_UPDATE PROSPECTS_INSERT_UPDATE DOCUMENTS_VIEW DOCUMENTS_INSERT_UPDATE My route guard: @Injectable() export class UserRouteAccessService implements CanActivate { userActions=[]; constructor(private