From dd8f6673f42986c507a7c3b19c5a976b691015cb Mon Sep 17 00:00:00 2001 From: StephanieJKS <47713197+StephanieJKS@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:16:24 +0200 Subject: [PATCH] feat(community-plugin-mongodb): Add support for a removed field on the user object.. --- .changeset/fair-turkeys-care.md | 5 +++++ .../MultiAppMongoDBAdapter/createDatabaseUserFromContact.js | 2 +- .../adapters/MultiAppMongoDBAdapter/getUserFromDbByEmail.js | 1 + .../adapters/MultiAppMongoDBAdapter/getUserFromDbById.js | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/fair-turkeys-care.md diff --git a/.changeset/fair-turkeys-care.md b/.changeset/fair-turkeys-care.md new file mode 100644 index 0000000..4def737 --- /dev/null +++ b/.changeset/fair-turkeys-care.md @@ -0,0 +1,5 @@ +--- +'@lowdefy/community-plugin-mongodb': minor +--- + +Add support for a removed field on the user object. 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 b23d5c5..06cd5e6 100644 --- a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js +++ b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/createDatabaseUserFromContact.js @@ -13,7 +13,7 @@ async function createDatabaseUserFromContact({ throw new Error('Access denied.'); } - if (contact.disabled || contact.apps?.[appName]?.disabled) { + if (contact.disabled || contact.removed || contact.apps?.[appName]?.disabled) { throw new Error('Access denied.'); } diff --git a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbByEmail.js b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbByEmail.js index b442c9f..083c8a6 100644 --- a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbByEmail.js +++ b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbByEmail.js @@ -8,6 +8,7 @@ async function getUserFromDbByEmail({ appName, collectionNames, email, mongoClie if ( !contact || contact.disabled || + contact.removed || !contact.apps?.[appName]?.is_user || contact.apps?.[appName]?.disabled ) { diff --git a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbById.js b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbById.js index 5c0599a..456c8e7 100644 --- a/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbById.js +++ b/plugins/community-plugin-mongodb/src/auth/adapters/MultiAppMongoDBAdapter/getUserFromDbById.js @@ -8,6 +8,7 @@ async function getUserFromDbById({ appName, collectionNames, mongoClient, userId if ( !contact || contact.disabled || + contact.removed || !contact.apps?.[appName]?.is_user || contact.apps?.[appName]?.disabled ) {