akveo / akveo/nebular

NbAuthService token not cleared on logout if not subscribed to the returned observable

Ouverte
#2,662 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
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.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.