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