I have a cloud function which should create a new user document as soon as user otp validation completes successfully.
But when i create user from appwrite cloud , it seems to add that document and when i add a user from my app , the event doesnt trigger.
Problem 1 = Function not executed as event not triggering
Problem 2 = How to create a document only when user validates/verifies otp successfully.
Summary
Users are experiencing two problems:
1. The users.*.create event is not triggering as expected when adding a user from their own app.
2. They want to know how to create a document only when a user successfully validates/verifies their OTP.
Solution:
- To fix problem 1, they should use the users.*.verification.*update event to trigger the function when OTP validation completes successfully.
- To solve problem 2, they can enable an option in the settings/cli or trigger the function on session creation, ensuring that it only executes once for each user.
anyuru
Rank 2: Process
Apr 28, 2023, 09:17
Use users.*.verification.*update to trigger the function when the as soon as the user otp validation successfully completes. It's the last part in this section of the documentation https://appwrite.io/docs/events
Prateek Jain
Rank 1: Thread
Apr 28, 2023, 09:20
there is no users.*.verification.*update option in appwrite cloud
joeyouss
Apr 28, 2023, 11:47
Hi - are you using the private cloud beta? just to confirm
Prateek Jain
Rank 1: Thread
Apr 28, 2023, 13:23
yes
Drake
Admin
Apr 28, 2023, 17:29
How to create a document only when user validates/verifies otp successfully
basically i need to create an user document when the user successfully logs in first time in our application
Prateek Jain
Rank 1: Thread
May 6, 2023, 08:28
it should not trigger for sessions as it will be many times for a particular user.
Prateek Jain
Rank 1: Thread
May 6, 2023, 08:30
@Steven can u please let me know what is the best way to this simple step.
Drake
Admin
May 6, 2023, 14:14
I suggest triggering on session creation but you can do some logic to make sure the rest of your function only executes once for the user
Prateek Jain
Rank 1: Thread
May 6, 2023, 14:38
ok sir.. but this should be fixed as that would be regular requirement for all.
Or basically we can provide (enable) a simple option in settings/cli to create a user document in a user named collection whenever a user is done verified in auth user.