From 2e8230ee6003d3e71d7e7725df9059282fa95eab Mon Sep 17 00:00:00 2001 From: Aelita4 Date: Mon, 23 Sep 2024 13:04:47 +0200 Subject: [PATCH] Fix bug with logging in --- src/lib/db/accessTokens.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/db/accessTokens.ts b/src/lib/db/accessTokens.ts index df99ce6..e3a3a81 100644 --- a/src/lib/db/accessTokens.ts +++ b/src/lib/db/accessTokens.ts @@ -6,7 +6,17 @@ import AccessToken from '../../types/AccessToken'; import locationManager from '../classes/managers/LocationManager'; 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; }