I am trying to create an OTP verification process wherein through the signup route, the user will enter the signup details such as phone number, gender. The function will save the data along with an OTP to an OTPdata model schema. In the verifyOtp route, the user will enter the OTP, and the function will check if the otp already exists, if it does, it will copy the whole document to other User model. I don't know how to copy documents of one model to other based on certain condition (if it has the same the otp the user entered). Can anyone help me? Or is there any better approach?
Related
I have a cloud firestore collection of users, all with the name, username, email, password and follower fields and basically what i am trying to do in this app is create a follow button and an unfollow button. When the follow is clicked, i want the followers field of that particular user to be updated with the 'username' of the current user and when i click the unfollow button, i want the username to be removed.How do i go about doing this? P.S Adding the username of the current user to the followed users follower field is just how i thought it would make sense so if there are better way to solving this, i am absolutely open to them
from my opinion
you may need to create a list/array of followers and every time user
hits follow button it adds this user to this list
or
you can do junction table put simply you will need to create a collection named USERID_FOLLOWERS and every time user hits its just
add or remove specific document and this is better to deal with big
data
I am new to flutter(and coding),I don't know if I specified the question clearly but what I want is for when a user "Follows" or "subscribe" to a product it goes to a listview but it changing the data globally in firestore, so in every user's listview has the same data subscribed. I want make it personalized for that specific user only, other can change the data too which will only affect that specific user only,
think of it as ecommerce cart function where every user has different thing in the cart
I did make a collection for "product" but every user getting data from same collection and it changing globally.
how can I make common subscribed data personalized for each user which will not conflict with others data.
how can I make common subscribed data personalized for each user which will not conflict with others data.
Every Firebase user has an id, you can use the user's id and set/query documents based on that.
For example, to set the data:
.collection('bla').doc(USER_ID).set({"name": "John"})
and to retrieve the data based on the id:
final snapshot = await Firestore.instance
.collection('bla')
.doc(USER_ID)
.get();
See also
How to get the current user id from Firebase in Flutter
I have a flutter app using firebase and google cloud. The organization providing the app to their users uploads a list of users that are able to register and create an account. When a user goes to register I want two things to happen:
They are given an error message if their email address and ID number do not match an existing document with email and ID field values
Existing fields, like their department and deck number that are in the collection uploaded by the organization are copied to their new user profile
I would write a cloud v2 function. The documentation has some great examples of how to block registration. What you would want to do is in the beforeUserCreated method, look up the field in firestore to validate that their email. You can get their email through the AuthBlockingEventType additionalUserInfo field which should provide the username (email in this case) to compare against the firestore database.
Deploying an AuthBlocking function is the same deployment as any other function.
Once deployed, you will need to remember to register your blocking function for it to take effect.
As far as updating their user profile information, you could just use another cloud function to listen for a database change once the user is registered and then copy that data over.
I am builing a flutter firestore app in which I want to be able to send a referral code to a new user and per referral code only one new user should be able to join.
Please tell me how can I implement this in in flutter app.
Thanks.
You can generate them with function you like, store them as documents in separate collection (document name is referral code - this will give you uniqueness of codes) then when user uses it you write his auth id in special field. Then in security rules you make rules that field may be updated only if there is no id there already.
Is it possible to have a validation process with an email before updating a field from an eloqua form into the eloqua database ?
ex: my form integrates a field called "Persona" . This field is an important information so I want to be able to collect it in all Eloqua forms I produce. However, if I have already collected this information from a contact and this contact is entering a data in a new form which is not consistent from previous data stored I would like to be able to send him an email to ask him if he/she really wants to validate this new value before updating it? Is it possible to do this ? Has anyone done this in practice already ? Any feedback ?
Rgds
Xavier
Ps: prefilling is not always possible because some form respondents might come from social media and not be recognized by a cookie
Pss: once updated the field is updated once a night with Website contact database. An alternative is to capture this field from eloqua form only if this field was empty in eloqua. If not then a user needs to go to website contact database with password-based login to change the value. The drawback is that you have to create a web contact for each persone filling in an eloqua from and this may require minimum level of information you would not have asked in some of the eloqua forms otherwise
You could prefill the data by performing a data lookup on the contact's email address (cookie or not). When the user completes their email address, use a script to lookup against the Eloqua contact database, and return the field values in the background. Upon submission of the form, do a diff check on the values entered vs the values you retrieved from the database. Output the result and submit that in another field through the form, then use that data after the fact. Maybe you could create an algorithm that sets a threshold for a significant change, set a boolean to true when that threshold is met, then trigger a campaign to send an email with their new values in the body, confirming if that is correct.