Reputation: 803
I want to change some fields in user details that correspond to a certain e-mail id manually.
Currently I have to look in authentication console for the e-mail id corresponding to UID(which is basis of storing user details now) but I don't want to do that.
Another option I thought was storing user details on the basis of their mobile numbers(as it is equally easily recognisible as email-id), but this will make login system on the basis of phone number instead of email-id.
Main problem is dot in email-id's that don't let email-id's to store as keys.
Upvotes: 0
Views: 60
Reputation: 138944
It's true, Firebase does not allow in it's key symbols like .
(dot). There are also other symbols like $
(dollar sign), [
(left square bracket), ]
(right square bracket), #
(hash or pound sign) and /
(forward slash) that are also forbidden.
So in order to solve your problem, you need to encode the email address like this:
[email protected] -> name@email,com
To achieve this, i recomand you to use the following method:
static String encodeUserEmail(String userEmail) {
return userEmail.replace(".", ",");
}
And to decode the email, you can use the following method:
static String decodeUserEmail(String userEmail) {
return userEmail.replace(",", ".");
}
Upvotes: 2