diff --git a/src/api/private/tokens/tokens.controller.ts b/src/api/private/tokens/tokens.controller.ts index 780e11be2..af2aa792f 100644 --- a/src/api/private/tokens/tokens.controller.ts +++ b/src/api/private/tokens/tokens.controller.ts @@ -48,7 +48,6 @@ export class TokensController { @Delete('/:keyId') @HttpCode(204) async deleteToken(@Param('keyId') keyId: string) { - // ToDo: Get real userName - return this.authService.removeToken('hardcoded', keyId); + return this.authService.removeToken(keyId); } } diff --git a/src/auth/auth.service.spec.ts b/src/auth/auth.service.spec.ts index e5375e15d..ae57414a3 100644 --- a/src/auth/auth.service.spec.ts +++ b/src/auth/auth.service.spec.ts @@ -152,7 +152,7 @@ describe('AuthService', () => { describe('removeToken', () => { it('works', async () => { - await service.removeToken(user.userName, authToken.keyId); + await service.removeToken(authToken.keyId); }); }); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 10a427ced..e37535104 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -141,10 +141,9 @@ export class AuthService { return user.authTokens; } - async removeToken(userName: string, keyId: string) { - const user = await this.usersService.getUserByUsername(userName); + async removeToken(keyId: string) { const token = await this.authTokenRepository.findOne({ - where: { keyId: keyId, user: user }, + where: { keyId: keyId }, }); await this.authTokenRepository.remove(token); }