How to add user details to Firestore DB after email verification in Flutter? - flutter

I am trying to add users information like email, name etc. to Firestore DB but after email successful verification. How can I do it..?
Thanks

you should implement Firebase authentication to your app.
the flow should be something like this:
on firebase console go under authentication tab and enable email authentication
in your app request user to register/login with firebase authentication by email
after succesfull authentication your user can now write on firebase db
done
now you have to create a new user in the users "table" with a reference to the authentication user id (not mandatory but nice)

Related

Supabase - post user sign up verification step - can Supabase handle this logic?

I am experimenting with Supabase as a replacement for Firebase.
When it comes to the Authentication functions, I am trying to replicate what is offered in Firebase.
With Firebase, if you create a new email/password user, then Firebase will send out a 'verify user' email to that user, and within the email there is a link back to the Firebase service that when clicked will action the verify user use case.
I can't find the equivalent verify user feature in Supabase. The Supabase admin console has a facility to define a URL, but I can't find anyway for Supabase to handle this use case. I'm inferring that with Supabase I will need to create a URL somewhere that when called will action the 'verify user' use case. That seems like a serious gap to me.
Any suggestions?
In Supabase, on the Authentication settings for your project under Email Templates you can customize the template and under URL Configuration you can set the redirect pages for the account confirmations. Note that the url for the confirmation of the user (at least for the free tier I've used, here's an example from the docs: https://project-ref.supabase.co/auth/v1/verify?token={{ .TokenHash }}&type=signup&redirect_to=https://example.com/path) is a Supabase URL, once clicked the user will be redirected to the custom set URL.
Check the official documentation for the Email Templates for more info.

Is there a way to add providers to an auth existing user? - Supabase - Flutter

With Firebase, I was able to do the following:
final credential = GoogleAuthProvider.credential(idToken: idToken);
//OR OTHER PROVIDERS
final credential = EmailAuthProvider.credential(email: emailAddress, password: password);
//ADD PROVIDER TO CURRENT USER
FirebaseAuth.instance.currentUser?.linkWithCredential(credential);
With Supabase I know these two things; users can be created with OAuth providers and, if the email of that provider user matches an existing user email, the provider is automatically added to that existing user. What I don't know is how to add providers to a user manually.
Example 1:
App requires every user to have an Email & Password
User signs up with phone auth or OAth
User needs to add Email & Password provider to their profile
Example 2:
User signs up with an Email & Password provider
User wants to be able to sign in with OAuth or phone auth
User needs to sign in to OAuth then that provider should be added to the existing Email & Password account
Currently in Supabase email address is the unique identifier of users. If a user that has signed up with email and password also signs up with their Google account using OAuth with the same email address, those two accounts will automatically be merged.

user/password and oath2 registration flow with Flutter + Firebase + Flask Backend

I am building a mobile app with Flutter and Flask Backend. For authentication, we allow username/password and google oath2 but will delegate to Firebase for credential validation.
So users credentials are stored on Firebase project but problem is we have a seperate Database with account table (we use a firebase_uuid field in account table to map to user on firebase project)
I am not sure of the registration flow since we need to handle both databases
For user/password registation, should Flutter app or Backend communicate to Firebase to create account?
I think backend should do it since after creating account on Firebase, we also need to create account on our own DB?
If we let flutter send request to Firebase directly to create account, what would be the correct flow so that my backend can also save user info in our BE database?
For google oath2 registration, similarly, if we were to do it on Flutter, what would be the flow to populate in our BE database?
Similarly, what is the flow in case of login and changing user's password?
Its pretty simple if we do not have Backend at all and just use firebase as backend but other operations required a seperate BE service

How to restrict anyone from signning-in using google sign-in in flutter?

I want only people whom I register or with specified email should be able to use google sign in, rest are not allow to sign in.
example:- I run a institution and I have separate id for my fellow students and I want them to only be able to sign in using that id and otherwise they should not be allowed to use any other Id(email to be more precise).
in my flutter application using firebase-> google_sign_in.
hope I am clear!
bro add some g mails in your firestore those people you want they can access my app if this emails exist in your db then they can google signin otherwise show toast your account is not regirsted by admin
try{
FirbaseFirestore.instance.collection("alloweduser).doc().where("emial",isequalto:123#gmail.com).then(){
Goolglesinin()
{
google signcode
}
}.catch(e)
{
showToast("ask admin to app permission")
}
You are talking about authentication vs. authorization.
Authentication: Since google is your authentication provider... anyone with a valid google account is authenticated.
Authorization: Who has access to what parts of the application?
You need to implement an authorization system / flow to determine if an authenticated user has access to the app. By default... all users will have NO ACCESS.
How you implement authorization - depends on your backend and how you store user data. If you are using firebase, something like this will help: https://firebase.google.com/docs/firestore/solutions/role-based-access

Is there any option in Firebase/Firestore for custom username and password authentication in flutter app?

I searched a lot on the net but couldn't find a solution to creating a login app which validates username and password from Firestore/Firebase, I don't need the providers already mentioned in the Firebase such as Google-sign in, email, phone etc.
Do I need to create my own Database and write the authentication code myself or Firebase has an option for this.
Edit: I want to have a custom username and password to be authenticated from the database. Is there any option for this in Firebase?
Thanks in advance.