我正在尝试解决用户在系统中冒充其他用户后遇到的问题。目前,区域用户可以冒充其他不加载页面全部内容的人,因为他们现在必须按 F5 才能查看此页面上的所有内容。我试图通过指向本地相同的数据库来重现此问题,但无法这样做。例如,当我转到 DEV url 时,我尝试冒充另一个用户,然后部分加载页面并刷新页面 (F5),我看到了整个内容。我相信这是由于路线导航而发生的,不确定我是否遗漏了要传递此函数的任何内容。
this.router.navigate(['/', user.Company.Abbreviation.toLowerCase()]);
这是 Impersonate 按钮正在执行的全部功能。
setImpersonatation() {
this.store.dispatch(new AuditSearchClearAction());
this.store.dispatch(new CompanyChangedAction(this.impersonationForm.value.company, null));
const user = this.impersonationForm.value.user as UserLogin;
this.store.dispatch(new BaseUserSetAction(user as User));
this.store.dispatch(new AuthorizeAction(user));
this.router.navigate(['/', user.Company.Abbreviation.toLowerCase()]);
this.store.dispatch(new MyWorkSetLetterReminderUserAction(user.UserId));
}
我是否需要向 router.navigate 添加任何参数以便正确加载页面?单击“模拟”按钮后尝试加载页面时似乎缺少某些内容。谢谢!
更新:
setImpersonatation() {
this.store.dispatch(new AuditSearchClearAction());
this.store.dispatch(new CompanyChangedAction(this.impersonationForm.value.company, null));
const user = this.impersonationForm.value.user as UserLogin;
this.store.dispatch(new BaseUserSetAction(user as User));
this.store.dispatch(new AuthorizeAction(user));
this.store.dispatch(new MyWorkSetLetterReminderUserAction(user.UserId));
**this.changeDetector.detectChanges();
this.router.navigate(['/', user.Company.Abbreviation.toLowerCase()]);**
}

