feat(web,server): logout all devices (#2415)

* feat: logout all devices

* chore: regenerate openapi

* chore: add test

* chore: logout vs log out
This commit is contained in:
Jason Rasmussen
2023-05-09 15:34:17 -04:00
committed by GitHub
parent c956eee919
commit a808b9403e
11 changed files with 241 additions and 4 deletions
@@ -163,6 +163,16 @@ export class AuthService {
await this.userTokenCore.delete(authUser.id, deviceId);
}
async logoutDevices(authUser: AuthUserDto): Promise<void> {
const devices = await this.userTokenCore.getAll(authUser.id);
for (const device of devices) {
if (device.id === authUser.accessTokenId) {
continue;
}
await this.userTokenCore.delete(authUser.id, device.id);
}
}
private getBearerToken(headers: IncomingHttpHeaders): string | null {
const [type, token] = (headers.authorization || '').split(' ');
if (type.toLowerCase() === 'bearer') {