【发布时间】:2019-03-05 01:48:34
【问题描述】:
我已经看到可以通过包含这个来更改 Jhipster 登录页面,
registerAuthenticationSuccess() {
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
if (account.authorities.indexOf('ROLE_CONTRACTOR') >=0)
{
this.router.navigate(['/property']);
}
else
{
this.account = account;
}
});
});
}
在 home.component.ts 中并在 onInit 方法中调用它,
this.principal.identity().then((account) => {
this.account = account;
});
this.registerAuthenticationSuccess();
但是,就我而言,这不起作用。在我的主页中,我只定义了管理员权限才能访问 route.ts 文件中的主页,如下所示,
export const HOME_ROUTE: Route = { path: '', component: HomeComponent, data: { authorities: ['ROLE_ADMIN'], pageTitle: 'home.title' }, canActivate: [UserRouteAccessService]};
但是当我以承包商身份登录时,我被重定向到登录页面,说我没有访问主页的权限。它不会被重定向到属性页。
【问题讨论】:
标签: jhipster