Working on navigation with authorization. This is a snippet of my code:
run(navigationInstruction: NavigationInstruction, next: Next) : Promise<any> {
let requiredRoles = navigationInstruction.getAllInstructions()
.map(i => i.config.settings.roles)[0];
toastr.success('TEST1');
let isUserInRole = requiredRoles?
requiredRoles.some(r => r === this.userIdentity.role) : true;
toastr.success('TEST2');//LINE IT`S NOT EXECUTED
return isUserInRole? next() : next.cancel(new Redirect('users/login'));
}
requiredRoles - Checked and returning value as expected.
In the line
r => r === this.userIdentity.role
, Visual Code shows a message: Parameter 'r' implicitly has an 'any' type, but a better type may be inferred from usage.ts(7044)