fix(auth-service): typeorm query in getTokensbyUser

TypeORM does not support WHERE queries for relation-colums directly.
This replaces the Equal() constructor with a manual comparison of the IDs.

See https://github.com/typeorm/typeorm/issues/2707

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-06-26 23:25:53 +02:00 committed by Yannick Bungers
parent e52cf4b4ae
commit 921cffb76f

View file

@ -160,10 +160,9 @@ export class AuthService {
}
async getTokensByUser(user: User): Promise<AuthToken[]> {
const tokens = await this.authTokenRepository
.createQueryBuilder('token')
.where('token.userId = :userId', { userId: user.id })
.getMany();
const tokens = await this.authTokenRepository.find({
where: { user: { id: user.id } },
});
if (tokens === null) {
return [];
}