Questions tagged [canactivate]

145 questions
0
votes
1 answer

Angular route protection with AuthGuard use only one time

i am protecting all my routes with a single Authguard and right now i am using in each route canActivate: [AuthguardService] my application has 30+ routes and so i need to type this 30 times in each route. Is there a way to protect all my routes…
GreekSwiss
  • 37
  • 8
0
votes
1 answer

CanActivate, Cant map to subject

My group and I are building a website using angular for the client side. We're trying to use AuthGuard to lockdown the routes but are having trouble not being able to map to the subject. LoginService: import { HttpClient, HttpErrorResponse } from…
0
votes
1 answer

canActivate is blocking all routes when logged in, Angular 13

I am struggling to figure out what is going on with my canActivate Method. Currently, I am able to log in and see that my user credentials are being saved and used in both localStorage and a console.log() so I know that I am creating them. I can…
M. Bal.
  • 43
  • 2
  • 6
0
votes
1 answer

How to return a value after `retryWhen` expires? (for `canActivate` guard)

When I reload my page, it always goes to blank page instead of the same page. The reason behind this is canActivate method which is cheking for user's permission gets invoked as soon as user refreshes the page and it is not able to get user data…
0
votes
1 answer

Role based permissions system

I've never done this before and couldn't find a good reference online so I'm asking. I'm building angular web app and want to make a role -> permission system. I've made roleGuard with CanActivate, but I cannot find a good way to make logic for…
reznov46
  • 26
  • 3
0
votes
1 answer

Angular Router route guard CanActivate always returns false

I have used CanActivate to protect a page but it always returning false because of that I can not access the protected router. I tried many ways, but was not successful to fix the issue. I am new to angular and I am stuck in validating the condition…
sarasm
  • 305
  • 1
  • 6
  • 16
0
votes
1 answer

Angular Routing to Child path based on role

After successful login, I redirect to following path this.router.navigate(['/main/']) Based on role received from login. Is it possible to redirect to diff modules. Example: If Role is 'Admin' if I redirect to ['/main'] based on role it will…
0
votes
1 answer

Redirect to a specific page when using CanActivate

In my application when a user try to see the page "home" he is redirected to the login page (if he's not already logged in). If the user is already logged in, or after he logged in, I want to redirect him to the page "home" or whatever page he was…
Matt
  • 265
  • 4
  • 17
0
votes
1 answer

How to take window ID of a created process in c#?

I am working on a C# .net core project.I created a process to run "xdotool windowactivate $windowpid".I should store the windowID which process run on it.The solution could be any property of xdotool which i couldn't find,or Is there any way to take…
sum
  • 1
  • 3
0
votes
1 answer

How to process data from api response then return a boolean value synchronously in angular?

I have a simple function in my service: /** * Funtion to check if the user logged in has admin rights */ isAdmin(user_id: string) { var adminTemp: boolean; this.httpClient .get(`${this.urk}/${user_id}`) …
Rohit Kumar
  • 684
  • 2
  • 17
  • 39
0
votes
1 answer

make delay in canActivate till IP address data is fetched

I'm making a guard for my angular application where all users should be redirected to maintenance page except for certain IPs. I'm getting the client IP address using third party APIs like http://api.ipify.org/?format=json. The PROBLEM I'm facing is…
surjendu_dey
  • 578
  • 2
  • 11
  • 28
0
votes
1 answer

How to pass a boolean parameter from Route Guards in Angular

I need to guard the routerLinks based on some boolean configurations coming from a server. Currently i have written canActivate route guard. ActivateRoutes file async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot):…
0
votes
0 answers

angular router endless loop when navigated from from canActivate

As angular routers need static paths, I am using canActive to dynamically route my app. my main routing is as follows. import { NgModule } from "@angular/core"; import { RouterModule } from "@angular/router"; import { AuthGuard, AuthData} from…
0
votes
1 answer

Angular canActivate get updated variable from service

I have a post request from a service which returns if a user is logged in, and I want to set a authGuard to only show the admin panel when they are logged in. My post request is as follows: public isLoggedIn: boolean = false; checkSesh(data: object)…
DevStacker
  • 675
  • 10
  • 23
0
votes
1 answer

Angular canActivate function in guard executed twice

I'm using Angular 8, and I have a guard that opens a page in a separate tab using window.open(url) if a specific condition is met, then returns false because I don't want to leave the current page I am on. I am doing this logic in the canActivate…