NbAuthService token not cleared on logout if not subscribed to the returned observable
- Ngôn ngữ chính
- TypeScript
- Star
- 8.1k
- Fork
- 1.5k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
Because the token is only cleared inside of a switchMap pipe, that logic isn't executed when we call logout() without subscribing to the returned observable...
Which means that you don't actually get logged out without subscribing after calling logout(), and there is no onAuthenticationChange update sent as expected...
If you just want to trigger a logout without having any follow-up logic duplicated everywhere and instead want to rely on a central onAuthenticationChange listener to handle the logout for the entire application, you still need to have a bunch of `logout(...).subscribe(() => {})` everywhere...
https://github.com/akveo/nebular/blob/bf7e2a3987f37f559ad0f8ffed92fddd46eaae45/src/framework/auth/services/auth.service.ts#L139-L143
This method should actually convert the outcome of `this.getStrategy(strategyName).logout()` into a promise and return it as such:
```
logout(strategyName: string): Promise {
return this.getStrategy(strategyName).logout().toPromise().then((result: NbAuthResult) => {
if (result.isSuccess()) {
this.tokenService.clear()
.pipe(map(() => result));
}
return result;
});
}
```
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.