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; }