This question already has answers here:
How to know if user's email is already registered
(2 answers)
Check if an email already exists in Firebase Auth in Flutter App
(5 answers)
Closed 11 months ago.
I am trying to create a user using createUserWithEmailAndPassword(email: email, password: password).
However in the error if a user account already exists for the email address, I would like to know if the provider is Facebook, Google, Email, etc.
Currently it only tells me 'email-already-in-use'.
So from a user point of view, if I don't remember that I have used Google Login before it will be impossible to login or create a new account because the error message doesn't tell me that I already have an account with same email address using Provider Google.
I would like to know how can I get the provider of the email address for which account already exist, to improve the user experience.
Related
This question already has an answer here:
What does MultiFactor mean in Firebase Auth
(1 answer)
Closed 1 year ago.
I am using the Firebase authentication service to offer various logins for my users. I also configured the standard "email/password" login and would like to add 2FA support to the login procedure.
I know Firebase offers a password-less login as well, but I prefer the default email+password+2FA approach where 2FA uses either Email or text message.
Am I missing something or is this option not available?
EDIT: THE BELOW ANSWER IS FOR EMAIL VERIFICATION. NOT 2FA.
The option is available. You simply check if email is verified from your code.
For flutter, this is how you do it:
User? user = FirebaseAuth.instance.currentUser;
if (user!= null && user.emailVerified) {
// allow access.
}
Flutter docs
This question already has answers here:
Is it Possible? sending email verification before a record is created in firebase authentication? [duplicate]
(2 answers)
Verify a user's email address before confirming registration, with Flutter and Firebase
(1 answer)
Closed 1 year ago.
I have a Flutter mobile application which uses the Firebase email authentication. Users register themselves by entering username, password, current country and first and last name. When they register, I create a user document under the users collection which will have email as an id, first, last name, country, notification token. However once they verify their email address then only they can use all the features of the app.
My problem is, some users enters junk email address which does not exists. Due to this, I am ending up with having wrong email address in the Authentication as well as in my Firestore user collection too. Also as these are junk email addresses, they will never be able to verify and login.
Right now I have a Firebase scheduler function that deletes these unverified users (older than 30 days) from the Authentication as well as user collection.
I don't want to create any entry in the Firebase authentication as well as in the users collection until and unless the user verifies their email address. Or is there any other way to achieve this?
Thank you
One solution is to use Email Link authentication: the account will be created when the user completes the process.
Paul Ruiz (Firebaser) has written a complete article detailing how to implement this option: See the "Email Link (Passwordless Sign-In)" section.
FYI, the equivalent doc for the iOS and Android SDKs can be find here and here.
This question already has answers here:
Firebase authentication email customisation
(4 answers)
Closed 4 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Firebase supports password-less email logins. A user provides their email, and then Firebase emails them a login link.
https://firebase.google.com/docs/auth/web/email-link-auth
However, I don't see any way to change the email text. This is the default:
Sign in to project-XXXX
Hello,
We received a request to sign in to project-XXXX using this email address. If you want to sign in with your XXXX#XXXX.com account, click this link:
Sign in to project-XXXX
If you did not request this link, you can safely ignore this email.
Thanks,
Your project-XXXX team
The Authentication > Templates section of Firebase Console only shows the following options. None of them match the text above:
You cannot, Firebase prevent this in order to avoid being used for spam. If you want to change the email, you need to handle the flow by yourself.
More info/references:
https://stackoverflow.com/a/50077575/5869296
The way Firebase has the message content locked down makes sense to me (I am currently using the Firebase email/password authentication) -or I should say, makes sense for at least specifically for the password reset message.
For the email confirmation message, as #Kayce pointed out, user has to be logged in. I can only imagine that there was some security/spam concern that Firebase folks thought of that I cannot come up with.
If customization was allowed for password reset messages, anyone with an email list that they want to spam can write a simple app, customize the message to whatever they want and have Firebase send that message to any email address that they want to spam (but I understand the question was about email verification emails).
Strangely, they do allow edits of the password reset emails.
This question already has answers here:
How do I return a list of users if I use the Firebase simple username & password authentication
(7 answers)
Closed 6 years ago.
I'm using email/password authentication in Firebase. So every user has an email address. My users are in groups, and I want each user to be able to see all the other users in the group. Specifically, I want to display a list of emails in the frontend to the user. My question is not about how to make rules for that, but rather, how do I get a user's email addresses given a user ID? Note that I'm asking about getting a list of other users, not the currently signed in user.
I haven't found any SO answers showing how to get the email address of another user via auth(). I've seen suggestions to place the email in the /users collection under the user ID, but that seems incredible brittle to me to store the email addresses in both auth() and /users/$userId. Changing email addresses will be a nightmare. So there must be a way to get the emails from auth(), right?
Thanks!
If you want to retrieve the email address of a specific user, you can use the new Firebase Admin SDK.
admin.auth().getUser(uid)
.then(function(userRecord) {
// See the tables below for the contents of userRecord
console.log("Successfully fetched user data:", userRecord.toJSON());
})
.catch(function(error) {
console.log("Error fetching user data:", error);
})
See the documentation on retrieving user data.
As its name implies, the Admin SDK runs with elevated authorization and thus should only be run on trusted hardware, e.g. an application server you control.
As I commented: there is no API to get a list of users.
This question already has answers here:
How do I return a list of users if I use the Firebase simple username & password authentication
(7 answers)
Closed 6 years ago.
I am working on an android app based on Firebase and I am creating registration using authentication of users with their email addresses and passwords with method signInWithEmailAndPassword, I am able register multiple users and also able to see user on Firebase console. But, I want to get the list of all the registered users on Firebase Auth. I can get the current user using FirebaseAuth.getInstance().getCurrentUser(). But, I want to list all the registered users. So, is there anyway I can get the list of registered users?
You can't
The explanation is here How do I return a list of users if I use the Firebase simple username & password authentication
You can instead set the user's uid to users node in your database, I use that node to store other user's information. then you can get the number of childs under that node.