-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
7 changes: 6 additions & 1 deletion
7
examples/rn-connection-and-error/backend/auth/custom_user_data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{ | ||
"enabled": false | ||
"enabled": true, | ||
"mongo_service_name": "mongodb-atlas", | ||
"database_name": "AuthExample", | ||
"collection_name": "Users", | ||
"user_id_field": "user_id", | ||
"on_user_creation_function_name": "onUserCreation" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
examples/rn-connection-and-error/backend/functions/onUserCreation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable */ | ||
|
||
/** | ||
* Adds custom user data to the Users collection when a new user is created. | ||
*/ | ||
exports = async function onUserCreation(user) { | ||
const customUserDataCollection = context.services.get("mongodb-atlas").db("AuthExample").collection("Users"); | ||
try { | ||
await customUserDataCollection.insertOne({ | ||
// Save the user's account ID to your configured user_id_field | ||
user_id: user.id, | ||
// Store any other user data you want | ||
team: "service", | ||
}); | ||
} catch (e) { | ||
console.error(`Failed to create custom user data document for user:${user.id}`); | ||
throw e; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters