From 3e337fe6374e11c1393cbd2878ebf72dd5d8f9dd Mon Sep 17 00:00:00 2001 From: pilcrow Date: Tue, 6 Feb 2024 10:31:35 +0900 Subject: [PATCH] Fix Mongoose compatibility issues (#1412) --- packages/adapter-mongodb/CHANGELOG.md | 6 +++++- packages/adapter-mongodb/package.json | 2 +- packages/adapter-mongodb/src/index.ts | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/adapter-mongodb/CHANGELOG.md b/packages/adapter-mongodb/CHANGELOG.md index 16374f220..ba3ddd9f5 100644 --- a/packages/adapter-mongodb/CHANGELOG.md +++ b/packages/adapter-mongodb/CHANGELOG.md @@ -1,5 +1,9 @@ # @lucia-auth/adapter-mongodb +## 1.0.2 + +- Fix Mongoose compatibility issues + ## 1.0.1 -- Fix broken version tag in package.json [#1378](https://github.com/lucia-auth/lucia/pull/1378) \ No newline at end of file +- Fix broken version tag in package.json [#1378](https://github.com/lucia-auth/lucia/pull/1378) diff --git a/packages/adapter-mongodb/package.json b/packages/adapter-mongodb/package.json index d58cdfa00..c3927dd74 100644 --- a/packages/adapter-mongodb/package.json +++ b/packages/adapter-mongodb/package.json @@ -1,6 +1,6 @@ { "name": "@lucia-auth/adapter-mongodb", - "version": "1.0.1", + "version": "1.0.2", "description": "MongoDB adapter for Lucia", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/adapter-mongodb/src/index.ts b/packages/adapter-mongodb/src/index.ts index 9f66815c0..25ca7472e 100644 --- a/packages/adapter-mongodb/src/index.ts +++ b/packages/adapter-mongodb/src/index.ts @@ -39,7 +39,8 @@ export class MongodbAdapter implements Adapter { public async getSessionAndUser( sessionId: string ): Promise<[session: DatabaseSession | null, user: DatabaseUser | null]> { - const sessionUsers = await this.Session.aggregate([ + // await necessary for mongoose + const cursor = await this.Session.aggregate([ { $match: { _id: sessionId } }, { $lookup: { @@ -50,7 +51,8 @@ export class MongodbAdapter implements Adapter { as: "userDocs" } } - ]).toArray(); + ]); + const sessionUsers = await cursor.toArray(); const sessionUser = sessionUsers?.at(0) ?? null; if (!sessionUser) return [null, null];