我在这里看到了一些答案,但我无法解决我的问题。
我有一个名为 的新权限,ROLE_X
并且在登录后,我想将具有此权限的用户重定向到一个新模块,例如dashboard
。
如果用户具有像 的默认权限ROLE_USER
,他应该home
像往常一样被重定向到模块。
有人能帮我吗?我正在使用 Angular 1.x。谢谢。
在home.component.ts
:
registerAuthenticationSuccess() {
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
if (account.authorities.indexOf("ROLE_X") >=0)
{
this.router.navigate(['PATHTOYOURPAGE']);
}
else
{
this.account = account;
}
});
});
}
相反,您可以根据需要在 login.component.ts 中执行相同的操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句