Android Studio - Add username to an existing user - android

Good day, is it possible to add a username data into an existing user in firebase?
Example:
User registers their account, they will give basic information such as First & Last name, Email, Password. After that a setup profile page will prompt where it asks the user to add a profile picture and username. How do I transfer the Profile pic & username data to the ID/Existing account in the firebase.
Haven't tried anything yet since I still don't have an idea.

Related

Firebase Android Studio Reset Password : Ask user to enter new password twice from sendpasswordresetemail

I am developing an app on Android Studio using Firebase. There is an option for users that has forgotten password. They will be prompted to enter their email and using Firebase send sendPasswordResetEmail(email), where an email to reset their password will be sent. However, when clicking the link user is prompted to only enter their new password ONCE. For security purposes, is there a way to ask user to enter their new password TWICE instead of just ONCE?
The page when clicking the link in sendPasswordResetEmail
I've tried using Deep Link, Android App Link, Action Code Settings, or Sign-In Email Authentication Link but it all seems too complex and doesn't exactly match what I want.
All I want is for when users click forget password, they need to enter the new password TWICE instead of just ONCE, and obviously for some authentication step to confirm that it is the right user that has forgotten their password and not some random person.

How to Check is the user is for the first time in google sign in android

I am building an android application with java but when I am using the google sign-in auth with firebase time I don't know that is the user is already available in firebase auth.
BECAUSE: i want that if the user is not in firebase and just sign up with google then i will show him a screen where he can enter his bio (about) and if the user is already in firebase and sign in later I will not show him that bio screen
Thanks in Advance
It sounds like you're trying to store some profile information about your users in Firestore.
In that case, once the user is signed in, you should check if you already have a profile document for that user in the database. This is easiest if you use the ID of the user as the document ID in Firestore, for example Firebase Authentication's UID, or (if you're not using Firebase Authentication) Google's sign-in's account ID.
If the document exits, you know about the user already. If it doesn't exist, you'll want to send them to the profile screen to enter their bio.
you can store the email of the sigin user in database and on the time of signup you can check that the email is already in database or not.

how to check when a user has phone authenticated in Firebase?

I have an Android app where users are registered in the app with their phone number, I am using Firebase to store in Authentication their phone and their email and also I am saving in the Realtime Database their phone, their full name, and their email. The structure in the Realtime Database is as follows:
Auto-Generated ID
+16505553434: "some#email.com"
email:"some#email.com"
first name: "First name"
last name: "Last name"
phone: "+16505553434"
After the user has registered and signed out when they try to use the app again I want to: if the user exists I don't want to do phone authentication again this should happen only once when they register if the user exists in the database I want to just type their password and log in. But the problem is how will I check if the user is phone registered in Firebase.
If the user has registered I want to show a layout for the input password while if the user is not registered I want to show the OtpView so that the user to do phone authentication-registration.
When the user has signed out the FirebaseAuth.getInstance().getCurrentUser() is null so i cannot use that.
What can I do to check if the user is registered or not?
After the user has registered and signed out when they try to use the app again I want to: if the user exists I don't want to do phone authentication again this should happen only once when they register if the user exists in the database I want to just type their password and log in.
When a user is authenticated with the phone number, there is no password involved. The authentication is made using the verification code that is sent via SMS. So if the user signs out, there is no way he can simply log-in using a password. He can log-in again using the phone number or any other provider.
But the problem is how will I check if the user is phone registered in Firebase. If the user has registered I want to show a layout for the input password while if the user is not registered I want to show the OtpView so that the user to do phone authentication-registration.
You can simply check your database against the phone number to see if the user already has an account. A query like this might do the trick:
db.child("users").orderByChild("phoneNumber").equalTo("+16505553434");
If you get a result, it means that the users exist. To be able to let the user "log-in with a password", you need to enable this kind of authentication. You can do it very easily in the Firebase console. But bear in mind that this is another type of authentication that cannot be combined with the first one. Check the docs regarding Authenticate with Firebase using Password-Based. So you can either sign-in with the phone number or with the email and password. You cannot sign-in with a phone number and password.
When the user has signed out the FirebaseAuth.getInstance().getCurrentUser() is null so i cannot use that. What can I do to check if the user is registered or not?
When the user signs out, the FirebaseUser object is null. There is no way you can get data from that object. All you can do it to query the database.

can i login into a user's account if I just know UID in firebase [duplicate]

This question already has answers here:
Is auth.uid a shared secret?
(2 answers)
Closed 4 years ago.
i have a button and i know a user's unique UID generated by firebase after a user is created on the firebase console's authentication page, now upon clicking the button i want to login that user, is that possible? if yes how?
i don't want to use email and password, i want to login with just the UID.
I have tried creating custom token as shown here Cannot Resolve setCredentials in FirebaseOptions.Builder().setCredentials(...)
In my application i'm using a face recognition api, so the user can login by two ways:
1)manually by entering email, password and clicking sign in.
2)in the sign in page there is a button to sign in with face, clicking on which it scans the face and returns the UID of the user if exists, now i want to signin that user.
please help.
What you're trying to do is not possible. Client-based authentication requires that you provide credentials for the login, not just a uid. It would be a huge security hole if anyone using an app could log in just knowing a uid.
If you want to do something on behalf of a user without logging in, you should do that on a secure backend you control using the Firebase Admin SDK.
Then while creating the account the user should upload a picture and then you can use the firebase database to store the face details, email and password with UID as the key.
Then while logging in using the Face recognition, if the face details match with those in the database, then the user is logged in. But i don't think this is secure.

Google Sign In app identification

Imagine the following senario
User sign in my app using his google account.
What i need now is to grab his name, profile and background photo from his account.
User interact with my app and make a post to a server. (i am saving his name and avatar photo to the server)
other users can see his post together with his profile name and avatar.
Now if user decide to change his profile photo or name how data on my server would reflect his changes ?
Cant figure out the flow of the above process.

Categories

Resources