gpt4 book ai didi

node.js - 根据用户登录启用或禁用某些侧菜单内容

转载 作者:太空宇宙 更新时间:2023-11-04 01:24:52 24 4
gpt4 key购买 nike

我使用 Angular 2 创建一个 web,我想根据用户登录数据启用或禁用一些侧边栏组件,用户的登录数据存储在 json 中,并通过 Qwebchannel 将 token 传递到 locolhost 中进行身份验证,现在做什么我想要的是根据用户登录 token 启用或禁用某些侧边栏组件...

ReDirectToNextPage(user: string){
setTimeout(function () {
location.reload();
}, 1);
console.log('ReDirectToNextPage called from JS');
this.tokenStorage.saveToken("login#username:" + user);
this.router.navigate(['server-config']);
}
checkLogin() {

if (this.tokenStorage.getToken() != undefined && this.tokenStorage.getToken() != null && this.tokenStorage.getToken().indexOf("login") != -1) {
this.router.navigate(['server-config']);
} else {
const card = document.getElementsByClassName('card')[0];
setTimeout(function () {
card.classList.remove('card-hidden');
}, 700);
}
}

这就是我尝试过的,我正在获取登录用户的 token ,我只想显示向登录用户分配权限(权限因用户登录而异)谢谢

最佳答案

我没有太多使用 Angular 2,但我建议开始使用 Angular 6+,它涵盖了 TypeScript,但你需要的是通用的,ngIfAngularJS 示例:

<div *ngIf="isValid"> Data is valid. </div> 

Tutorial

stackoverflow angular 2 ngIf中的相同解决方案

如果您想禁用它,这可以帮助您: deactive angular button

例如,您有一个 jwt,因此您可以使用 bool 值来检查用户是否经过身份验证我希望这会对您有所帮助;)

关于node.js - 根据用户登录启用或禁用某些侧菜单内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57933022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com