From 1f3de71db2980c684d30eae251496437068a9730 Mon Sep 17 00:00:00 2001 From: Ioannis Ktistakis <47716028+Yianni99@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:25:35 +0200 Subject: [PATCH 1/3] fix(plugin-mongodb): Set includeResultMetadata option true on adapter. --- .changeset/shy-lobsters-turn.md | 5 +++++ .../MultiAppMongoDBAdapter/createDatabaseUserFromContact.js | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/shy-lobsters-turn.md diff --git a/.changeset/shy-lobsters-turn.md b/.changeset/shy-lobsters-turn.md new file mode 100644 index 0000000..6ded198 --- /dev/null +++ b/.changeset/shy-lobsters-turn.md @@ -0,0 +1,5 @@ +--- +'@lowdefy/community-plugin-mongodb': patch +--- + +Set includeResultMetadata option true on adapter. diff --git a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js index f7e602c..5fa0510 100644 --- a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js +++ b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js @@ -46,7 +46,11 @@ async function createDatabaseUserFromContact({ const { value: updatedContact } = await mongoClient .db() .collection(collectionNames.contacts) - .findOneAndUpdate({ _id: contact._id }, { $set: update }, { returnDocument: 'after' }); + .findOneAndUpdate( + { _id: contact._id }, + { $set: update }, + { returnDocument: 'after', includeResultMetadata: true } + ); return transformContactToAdapterUser({ appName, contact: updatedContact }); } From b0947e7b89bf3e4d2cf7da2ba2f0699ff52070c7 Mon Sep 17 00:00:00 2001 From: Ioannis Ktistakis <47716028+Yianni99@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:55:44 +0200 Subject: [PATCH 2/3] chore: Clean up createDatabaseUserFromContact. --- .../createDatabaseUserFromContact.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js index 5fa0510..b23d5c5 100644 --- a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js +++ b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js @@ -43,14 +43,10 @@ async function createDatabaseUserFromContact({ }; } - const { value: updatedContact } = await mongoClient + const updatedContact = await mongoClient .db() .collection(collectionNames.contacts) - .findOneAndUpdate( - { _id: contact._id }, - { $set: update }, - { returnDocument: 'after', includeResultMetadata: true } - ); + .findOneAndUpdate({ _id: contact._id }, { $set: update }, { returnDocument: 'after' }); return transformContactToAdapterUser({ appName, contact: updatedContact }); } From f5c100d49bdbd973ad9bcbd54ca9bb5701869234 Mon Sep 17 00:00:00 2001 From: Ioannis Ktistakis <47716028+Yianni99@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:21:23 +0200 Subject: [PATCH 3/3] chore: Update changeset. --- .changeset/shy-lobsters-turn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/shy-lobsters-turn.md b/.changeset/shy-lobsters-turn.md index 6ded198..f7b7127 100644 --- a/.changeset/shy-lobsters-turn.md +++ b/.changeset/shy-lobsters-turn.md @@ -2,4 +2,4 @@ '@lowdefy/community-plugin-mongodb': patch --- -Set includeResultMetadata option true on adapter. +Fixed issue where user login fails for an invited user on first signup.