(user: User)
| 86 | } catch (error) { |
| 87 | return { |
| 88 | message: 'Invalid or expired token', |
| 89 | success: false, |
| 90 | }; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Sign an account out everywhere, right now. Returns how many access |
| 96 | * tokens were killed. |
| 97 | * |
| 98 | * Both halves matter and neither is enough alone: the refresh tokens are |
| 99 | * what would mint a fresh session for up to 7 days, and the cached access |
| 100 | * tokens are what still work for up to 30 minutes. Anything that decides an |
| 101 | * account's sessions must end calls this rather than one of the two — |
| 102 | * password reset used to drop refresh tokens only, and admin deactivation |
| 103 | * dropped neither. |
| 104 | */ |
| 105 | async endAllSessions(userId: string): Promise<number> { |
| 106 | await this.refreshTokenRepository.delete({ userId }); |
| 107 | return this.jwtCacheService.removeTokensForUser(userId); |
| 108 | } |
| 109 |
no test coverage detected