Change createTokenForUser signature

user is now used instead of username

Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
Yannick Bungers 2021-10-13 22:59:51 +02:00
parent d33cfa4541
commit 325e1893f8
3 changed files with 8 additions and 24 deletions

View file

@ -15,7 +15,6 @@ import {
TooManyTokensError,
} from '../errors/errors';
import { ConsoleLoggerService } from '../logger/console-logger.service';
import { UserRelationEnum } from '../users/user-relation.enum';
import { User } from '../users/user.entity';
import { UsersService } from '../users/users.service';
import {
@ -58,13 +57,12 @@ export class AuthService {
}
async createTokenForUser(
username: string,
user: User,
identifier: string,
validUntil: TimestampMillis,
): Promise<AuthTokenWithSecretDto> {
const user = await this.usersService.getUserByUsername(username, [
UserRelationEnum.AUTHTOKENS,
]);
user.authTokens = await this.getTokensByUser(user);
if (user.authTokens.length >= 200) {
// This is a very high ceiling unlikely to hinder legitimate usage,
// but should prevent possible attack vectors