I am currently developing a JHipster project where I need to display different home pages based on the role of the user logging in. Specifically, I am utilizing Angular 1.x for this project. For instance, I have roles such as ROLE_ADMIN and ROLE_USER, each requiring a unique dashboard.
I came across suggestions that involve adding something like the following code block to my home.controller.js:
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
if (account.authorities.indexOf("ROLE_ADMIN") >=0)
{
this.router.navigate(['#/pages/prueba/prueba.html']);
}
else
{
this.account = account;
}
});
});
However, despite trying to implement it, I encountered an error message: Error: this is undefined.
Does anyone have any insights or solutions to this issue?