135 questions
0 votes
0 answers
60 views
Angular canDeactivate (Unsaved Changes Warning) works with route navigation but not inside custom slideout panel
I’m working on an Angular v15+ app that uses a custom slideout panel system for showing forms. We’re trying to show an “unsaved changes” confirmation popup when the user closes the slideout, similar ...
1 vote
2 answers
954 views
Angular Guard doesn't work when reloading page (v19)
Recently I have been through some trouble with my auth guard, which calls the API to check if current user is successfully logged in sending the auth cookie. This API returns a boolean value. The ...
1 vote
1 answer
53 views
Guard flickers page then loads actual page
export const authorizedUserGuard: CanActivateFn = (route, state) => { console.log('guard call', route, state) const tokenService = inject(TokenStorageService); const router = inject(...
1 vote
2 answers
271 views
Angular AuthGuard Not Blocking Access When Directly Navigating to blocked Routes
I'm working on an Angular application where I want to prevent authenticated users from accessing the login and signup pages. I have implemented an AuthGuard to handle this. The guard works as expected ...
1 vote
1 answer
262 views
CoreUI with Angular 18 - interceptor not intercepting http requests
I just started with coreUi and Angular 18 and would like to intercept the requests, when the user calls another route. I started with the standard coreUi modern theme and set everything up so far but ...
1 vote
0 answers
155 views
Angular: Guard after resolved data
I'm having a route /invoices/:invoiceId for an invoice detail view which needs to be protected with 2 conditions User needs to be authenticated --> Redirect to login page Invoice with given id ...
3 votes
4 answers
6k views
Angular 17 AuthGuard with Observable
Trying to get the following AuthGuard to properly redirect if a user is not logged in. export const authGuard: CanActivateFn = (route, state) => { const authService = inject(AuthService); const ...
2 votes
1 answer
204 views
angular 17 guard's Dependency injection got reinitialized or doesn't update
After login router.navigate goes to guard but in guard it doesn't get updated value. My app.config.ts is: export const appConfig: ApplicationConfig = { providers: [ provideRouter(routes), ...
3 votes
1 answer
2k views
inject in Authentication guard is giving me type any in angular 17
I create a functional guard in angular 17 import { Inject } from '@angular/core'; export const checkoutGuard: CanActivateFn = (route, state) => { const customerService = Inject(CustomerService)...
1 vote
0 answers
434 views
How to implement CanDeactivateFn in Angular15
I would like to implement a CanDeactivate Guard in my Angular application. I've found out, that I should use the new "CanDeactivateFn" Guard, but I can't found any information or an example ...
1 vote
1 answer
424 views
How to export a functional guard
I have a functional guard that I would like to export from one of my libraries. Initially the guard looked like this: export const canActivateAuthenticationFn: CanActivateFn = () => { const ...
1 vote
1 answer
475 views
How to redirect from guard in a module federated angular application
I have a module federated angular application where I have a route-guard that redirects to another route. When loaded as standalone application redirection works perfectly, problem occurs when it is ...
0 votes
1 answer
2k views
Functional Guards in Angular
I want to prevent navigation by changing the URL and only navigate on button click. My code: import {Injectable} from '@angular/core'; import {CanActivateFn, Router} from '@angular/router'; @...
0 votes
1 answer
806 views
Angular guard loop issue
I've been having issues with a guard loop and I'm trying to find out the best routing setup. Current routing structure... Root path with a guard on it. A child dashboard route with a resolver that ...
8 votes
1 answer
8k views
Testing a functional Angular Routing guard
Hello since the class guards are deprecated, I moved mine to a functional, but my test broke and I'm really confused of the injectable service of keycloak and the parameters of the guard. Here is the ...