I am encountering a problem where my canActivate method is returning false, but still navigating to the blocked screen. This issue seems to only occur in Chrome, as everything works fine in IE. Here is how the canActivate method looks:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.getDataFromApi(state.url)
.toPromise()
.then(result => {
return result;
});
}
Here is the getDataFromApi() method:
getDataFromApi(link): Observable<boolean> {
return this.http.get("api/security")
.map(response => {
var url = link.replace("/", "");
var data = response.json();
var privileges = data["privileges"];
var currentItem = privileges[url];
return currentItem["view"];
});
}
Is there any solution to fix this Chrome-specific issue? Your help is greatly appreciated.
EDIT I have tested in IE, Edge, and Firefox where the issue does not occur. In Chrome, it only works when the developer console is open.