Fix bug with logging in

This commit is contained in:
Aelita4 2024-09-23 13:04:47 +02:00
parent cc5d482a0f
commit 2e8230ee60
Signed by: Aelita4
GPG Key ID: E44490C2025906C1
1 changed files with 11 additions and 1 deletions

View File

@ -6,7 +6,17 @@ import AccessToken from '../../types/AccessToken';
import locationManager from '../classes/managers/LocationManager'; import locationManager from '../classes/managers/LocationManager';
export const createAccessToken = async (accessToken: AccessToken) => { export const createAccessToken = async (accessToken: AccessToken) => {
const newAccessToken = await (await AccessTokens()).insertOne(accessToken); const formatted: DBAccessToken = {
_id: new ObjectId(),
type: accessToken.type,
user: accessToken.user?.id ?? new ObjectId(0),
entropy: accessToken.entropy,
createdAt: accessToken.createdAt,
expiresAt: accessToken.expiresAt ?? new Date(accessToken.createdAt.getTime() + 86400000),
createdFrom: accessToken.createdFrom
}
const newAccessToken = await (await AccessTokens()).insertOne(formatted);
return newAccessToken; return newAccessToken;
} }