Split methods getAuthTokenAndValidate and createTokenForUser

Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
Yannick Bungers 2022-09-11 21:05:04 +02:00 committed by David Mehren
parent c835339633
commit 499f632d8d
5 changed files with 102 additions and 92 deletions

View file

@ -48,16 +48,16 @@ export class AuthToken {
keyId: string,
user: User,
label: string,
accessToken: string,
tokenString: string,
validUntil: Date,
): Omit<AuthToken, 'id' | 'createdAt'> {
const newToken = new AuthToken();
newToken.keyId = keyId;
newToken.user = Promise.resolve(user);
newToken.label = label;
newToken.accessTokenHash = accessToken;
newToken.validUntil = validUntil;
newToken.lastUsedAt = null;
return newToken;
const token = new AuthToken();
token.keyId = keyId;
token.user = Promise.resolve(user);
token.label = label;
token.accessTokenHash = tokenString;
token.validUntil = validUntil;
token.lastUsedAt = null;
return token;
}
}