AuthService: randomString does not need to by async

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-02-23 22:16:27 +01:00
parent fed3a12779
commit def4ef145e
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -62,7 +62,7 @@ export class AuthService {
return await compare(cleartext, password);
}
async randomString(length: number): Promise<Buffer> {
randomString(length: number): Buffer {
if (length <= 0) {
return null;
}
@ -93,8 +93,8 @@ export class AuthService {
`User '${user.userName}' has already 200 tokens and can't have anymore`,
);
}
const secret = this.bufferToBase64Url(await this.randomString(54));
const keyId = this.bufferToBase64Url(await this.randomString(8));
const secret = this.bufferToBase64Url(this.randomString(54));
const keyId = this.bufferToBase64Url(this.randomString(8));
const accessToken = await this.hashPassword(secret);
let token;
// Tokens can only be valid for a maximum of 2 years