NbAuthService token not cleared on logout if not subscribed to the returned observable
- Langage dominant
- TypeScript
- Étoiles
- 8.1k
- Forks
- 1.5k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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;
});
}
```
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.