From 275225a93f6f5f4afd8c20a9106b280a239a9bd6 Mon Sep 17 00:00:00 2001 From: "mongodb-atlas-app-services[bot]" <49962638+mongodb-atlas-app-services[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 06:06:29 +0000 Subject: [PATCH] Deployment from App Services --- app-1/auth/custom_user_data.json | 7 ++++++- app-1/functions/config.json | 4 ++++ app-1/functions/onUserCreation.js | 19 +++++++++++++++++++ app-1/functions/package.json | 1 + 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app-1/functions/onUserCreation.js create mode 100644 app-1/functions/package.json diff --git a/app-1/auth/custom_user_data.json b/app-1/auth/custom_user_data.json index a82d0fb..4674363 100644 --- a/app-1/auth/custom_user_data.json +++ b/app-1/auth/custom_user_data.json @@ -1,3 +1,8 @@ { - "enabled": false + "enabled": true, + "mongo_service_name": "mongodb-atlas", + "database_name": "db", + "collection_name": "Database", + "user_id_field": "Clusters", + "on_user_creation_function_name": "onUserCreation" } diff --git a/app-1/functions/config.json b/app-1/functions/config.json index b3356b2..53eb92f 100644 --- a/app-1/functions/config.json +++ b/app-1/functions/config.json @@ -2,5 +2,9 @@ { "name": "resetFunc", "private": true + }, + { + "name": "onUserCreation", + "private": false } ] diff --git a/app-1/functions/onUserCreation.js b/app-1/functions/onUserCreation.js new file mode 100644 index 0000000..18a8a7d --- /dev/null +++ b/app-1/functions/onUserCreation.js @@ -0,0 +1,19 @@ +/* + This function will run after a user is created and is called with an object representing that user. + + This function runs as a System user and has full access to Services, Functions, and MongoDB Data. + + Example below: + + exports = (user) => { + // use collection that Custom User Data is configured on + const collection = context.services.get("").db("").collection(""); + + // insert custom data into collection, using the user id field that Custom User Data is configured on + const doc = collection.insertOne({ : user.id, name: user.data.name }); + }; +*/ + +exports = (user) => { + return; +}; diff --git a/app-1/functions/package.json b/app-1/functions/package.json new file mode 100644 index 0000000..9e7783b --- /dev/null +++ b/app-1/functions/package.json @@ -0,0 +1 @@ +{"dependencies":{"Npm":"3.0.0"}} \ No newline at end of file