当我以超级用户用户身份登录我的应用程序时,成功登录后,键入存储在本地存储中的“超级用户”。但是,当我以管理员用户身份登录时,存储在localstorage中的'admin'用户类型被登录,它将调用只有超级用户才能访问的服务。
this.commonService.login(loginData).subscribe(res => {
let encodeCode = AES.encrypt(res['user'].organizationId, myGlobals.ENC_KEY).toString();
// if (res['user'].type == 'admin'){
// this.router.navigate(["../admin/organization/edit"], { queryParams: { id: encodeCode }, relativeTo: this.route });
// } else {
this.router.navigate([""]);
// }
this.spinner.hide();
Toast.fire({
type: 'success',
title: 'Logged in successfully'
})
this.isError = false;
localStorage.setItem('token', res['accessToken']);
localStorage.setItem("userInfo", JSON.stringify(res['user']));
let defaultSet: any = { org: true, user: true, flow: true, conn: true };
localStorage.setItem("default", JSON.stringify(defaultSet));
}, error => {
this.isError = true;
});
ngOnInit() {
this.searchValid();
if (this.userType.type == 'superuser') {
this.organizationList();
} else {
this.projectList();
}
$("#orgLink").addClass('active');
// Initialize Socket
if (myGlobals.SOCKET) {
this.initSocket();
}
}