简体   繁体   English

Angular和Typescript - 从管理员登录中停用其他用户时发出问题

[英]Angular & Typescript - Issue while deactivating other users from the Admin login

In my web application, when I login as ' Admin ', I will be able to view, activate , delete etc. the user profiles of my application. 在我的Web应用程序中,当我以“ 管理员 ”身份登录时,我将能够查看, 激活 ,删除我的应用程序的用户配置文件。 When admin activates an user profile, the user will be able to access the application. 当admin激活用户配置文件时,用户将能够访问该应用程序。 When Admin deactivates an user profile, the user will not be able to access the application. 当Admin取消激活用户配置文件时,用户将无法访问该应用程序。 The problem arises in the following scenario. 问题出现在以下场景中。 I am logged in as some ACTIVATED user XYZ in one browser (say IE). 我在一个浏览器(例如IE)中以某个ACTIVATED用户XYZ身份登录。 I am logged in as ADMIN in another browser (say Chrome). 我在另一个浏览器(例如Chrome)中以ADMIN身份登录。 Now, I am deactivating that activated user. 现在,我正在停用该激活的用户。

My expected behavior is, XYZ which is open in another browser should be logged out and be redirected to the Login page for a fresh sign-in. 我的预期行为是,在其他浏览器中打开的XYZ应该被注销并被重定向到登录页面以进行全新登录。 But right now, what happens is, even after deactivating XYZ, that session is in login state only. 但是现在,即使在停用XYZ之后,该会话仅处于登录状态。

I have tried n-number of ways to solve this issue but of no gain. 我已经尝试了很多方法来解决这个问题,但没有任何好处。 Since my code is too long, here is the snippet of code that deals with this issue. 由于我的代码太长,以下是处理此问题的代码片段。

HTML: HTML:

<tbody *ngIf = "users">
<tr *ngFor = "let user of users; trackBy: trackIdentity">
<td>
    <button class="btn btn-danger btn-sm" (click)="setActive(user, true)" *ngIf="!user.activated">Deactivated</button>
    <button class="btn btn-success btn-sm" (click)="setActive(user, false)" *ngIf="user.activated" [disabled]="currentAccount.login === user.login">Activated</button>
</td>
</tr>
</tbody>

Component.ts: Component.ts:

setActive(user, isActivated) {
user.activated = isActivated;
this.userService.update(user).subscribe(
(response) => {
if(response.status === 200) {
    this.error = null;
    this.success = 'OK';
    this.loadAll();
    }
else {
    this.success = null;
    this.error = 'ERROR';
    }
}}

Suggestions and code snippets that could possibly solve my issue are most welcome. 我们非常欢迎可能解决我的问题的建议和代码片段。 Workarounds in jQuery and Javascript are also welcome! 欢迎使用jQueryJavascript中的变通方法!

As you selected JWT authentication type, there's no session. 当您选择JWT身份验证类型时,没有会话。

Until his/her token expires, authenticated user will stay authenticated and authorized. 在他/她的令牌到期之前,经过身份验证的用户将保持身份验证和授权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM