Skip to content

Commit

Permalink
Fix Mongoose compatibility issues (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper authored Feb 6, 2024
1 parent e4a185f commit 3e337fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/adapter-mongodb/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
- Fix broken version tag in package.json [#1378](https://github.com/lucia-auth/lucia/pull/1378)
2 changes: 1 addition & 1 deletion packages/adapter-mongodb/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 4 additions & 2 deletions packages/adapter-mongodb/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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];
Expand Down

0 comments on commit 3e337fe

Please sign in to comment.