angular7 - 注销申请或清除本地存储值后,本地存储值仍返回之前的值
问题描述
当我以超级用户身份登录我的应用程序时,成功登录后,输入存储在本地存储中的“超级用户”。但是,当我以管理员用户身份登录时,“管理员”用户类型存储到本地存储中,它会调用管理员用户只能由超级用户访问的服务。
本地存储项设置为 userInfo 键的登录组件
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();
}
}
解决方案
推荐阅读
- r - 使用 RMySQL 加载名为“order”的 MySQL 表
- concourse - Concourse Pipelines 与 Pivotal Tracker 的集成
- php - 如何使用 Eloquent (Laravel) 关系插入记录?
- math - 仅使用度数使物体绕另一个轨道运行(不是仅弧度整数数学)
- javascript - 带有 exec ruby 的异步函数
- postgresql - 如何根据日期选择 postgres 表中的行并将其存储在新表中?
- c# - 带有 SelectMany() 的平面数据,如左连接
- bluetooth - 使用 GnuRadio 解码蓝牙信号和数据包
- mfc - 验证列表控件就地编辑
- matlab - 标准化图像时尺寸错误